Exam Indus

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#define KM1 PORTD.

RD4

#define KM2 PORTD.RD5

#define V1 PORTD.RD6

#define V2 PORTD.RD7

#define S1 PORTB.RB0

#define S2 PORTB.RB1

// Lcd pinout settings

sbit LCD_RS at RC2_bit;

sbit LCD_EN at RC3_bit;

sbit LCD_D4 at RC4_bit;

sbit LCD_D5 at RC5_bit;

sbit LCD_D6 at RC6_bit;

sbit LCD_D7 at RC7_bit;

// Pin direction

sbit LCD_RS_Direction at TRISC2_bit;

sbit LCD_EN_Direction at TRISC3_bit;

sbit LCD_D4_Direction at TRISC4_bit;

sbit LCD_D5_Direction at TRISC5_bit;

sbit LCD_D6_Direction at TRISC6_bit;

sbit LCD_D7_Direction at TRISC7_bit;

void main() {

TRISB=1;

TRISD=0;

PORTD=0;

PORTB=0;

while(1)

{
if(S1==1) {

PORTD=0;

KM1=1;

V1=1;

Lcd_Init();

Lcd_cmd(_Lcd_clear);

Lcd_cmd(_Lcd_cursor_off);

Lcd_out(1,1,"moteur marche avant");

else if(S2==1) {

PORTD=0;

KM2=1;

V2=1;

Lcd_Init();

Lcd_cmd(_Lcd_clear);

Lcd_cmd(_Lcd_cursor_off);

Lcd_out(1,1,"moteur marche arrière");

You might also like