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, 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; //initialize i
int j = 0;//initialize j
while(1)
{
PORTA = seven_seg[i]; //assigning port A as display 1
PORTC = seven_seg[j];//assigning port c as display 2
for(i = 0; i < 10; i++) //loop for seven segment dispaly
{
PORTC = seven_seg[i];
for(j = 0; j < 10; j++)
{
PORTA = seven_seg[j];
_delay_ms(500);
}
}
}

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.