Challenge

Project 1 - Controlling a DC motor using PWM and monitoring its Running status

Code

#include

#define F_CPU 16000000L

#include "avr/interrupt.h"

#include

#define sw_dir (PIND & (1<<1))

#define sw_dspd (PIND & (1<<2))

#define pw (PINC & (1<<3))

#define lcd_port PORTB

#define RS_high PORTD |= (1<<5)

#define RS_low PORTD &=~ (1<<5)

#define EN_high PORTD |= (1<<6)

#define EN_low PORTD &=~ (1<<6)

unsigned char i;

void lcd_cmd(char cmd)

{

lcd_port = (cmd & 0xf0);

RS_low;

EN_low;

_delay_ms(1);

EN_high;

lcd_port = ((cmd<<4) & (0xf0));

RS_low;

EN_low;

_delay_ms(1);

EN_high;

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.