logo

Modelling of Motors : 649479 - Assignment

10 Pages1504 Words45 Views
   

Added on  2020-04-29

Modelling of Motors : 649479 - Assignment

   Added on 2020-04-29

ShareRelated Documents
// led_blink.c- Motor Program 1#define F_CPU 14745600#include <avr/io.h>#include <inttypes.h>#include "../libnerdkits/delay.h"#include "../libnerdkits/lcd.h"// PIN DEFINITIONS://// PC4 -- LED anodeint main() { // Port C bit 3,4 and 5 as output DDRC |= (1<<PC4) | (1<<PC3) |(1<<PC2) ; // loop keeps looking forever while(1) {// turn on green Motor (PC2) and turn off others PORTC |= (1<<PC2);PORTC &= ~((1<<PC4) | (1<<PC3) ); //delay for 4000 milliseconds to let the Motor stay on delay_ms(4000);// turn on amber Motor (PC3) and turn off others PORTC &= ~((1<<PC4) | (1<<PC2) );PORTC |= (1<<PC3);
Modelling of Motors : 649479 - Assignment_1
//delay for 2000 milliseconds to let the Motor stay on delay_ms(2000);// turn on red Motor (PC4) and turn off others PORTC &= ~((1<<PC3) | (1<<PC2) );PORTC |= (1<<PC4); //delay for 3000 milliseconds to let the Motor stay on delay_ms(3000);// switch of all MotorsPORTC &= ~((1<<PC4) | (1<<PC3) | (1<<PC2) ); } return 0;}// led_blink.c- Motor Program 2#define F_CPU 14745600#include <avr/io.h>#include <inttypes.h>#include "../libnerdkits/delay.h"#include "../libnerdkits/lcd.h"
Modelling of Motors : 649479 - Assignment_2
// PIN DEFINITIONS://// PC4 -- LED anodeint main() { // Port C bit 2,3 and 4 as output DDRC |= (1<<PC4) | (1<<PC3) |(1<<PC2) ; // loop keeps looking forever while(1) {// turn on red motor (PC4) and turn off others PORTC |= (1<<PC4);PORTC &= ~((1<<PC2) | (1<<PC3) ); //delay for 3000 milliseconds to let the red motor to stay on delay_ms(3000);// turn off all motors for 1 sec PORTC &= ~((1<<PC2) | (1<<PC3) | (1<<PC4));//delay for 1000 milliseconds to let all motors off delay_ms(1000);// turn on green Motor (PC2) and turn off others PORTC &= ~((1<<PC4) | (1<<PC3) );PORTC |= (1<<PC2); //delay for 3000 milliseconds to let motor stay on delay_ms(3000);
Modelling of Motors : 649479 - Assignment_3

End of preview

Want to access all the pages? Upload your documents or become a member.