Challenge

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

MAGNA

#include <avr/io.h>
#define F_CPU 16000000L
#include <util/delay.h>
char seven_seg[10] = {0X3F, 0X06, 0X5B, 0X4F, 0X66, 0X6D, 0X7D, 0X07, 0X7F, 0X6F};

int main(void)
{
DDRC = 0XFF; //set port c as output
DDRA = 0XFF; //set port a as output
int i = 0;
int j = 0;
while(1)
{
PORTA = seven_seg[i]; //initialization of port a
PORTC = seven_seg[j]; //initialization of port c
for(i = 0; i < 10; i++) //loop for 10's digit
{
PORTC = seven_seg[i];
for(j = 0; j < 10; j++) //loop for unit digit
{
PORTA = seven_seg[j];
_delay_ms(1000); //delay generation
}
}
}
}

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.