-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotor_switch
34 lines (27 loc) · 1.1 KB
/
motor_switch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#define _XTAL_FREQ 20000000
#include <xc.h>
// BEGIN CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
//END CONFIG
void main()
{
TRISB0 = 0; //RB0 as Output PIN
TRISB1 = 0; //RB1 as output PIN
TRISD0 = 1; //D0 input as switch
RB0 = 0; //motor i/p Off
while(1)
{
if(RD0 == 1) //If Switch Pressed
{
RB0 = 1; //+ve ON
RB1 = 0; //-ve OFF
}
}
}