microcontroller class the 1st pic is the problem we are to w
microcontroller class. the 1st pic is the problem. we are to write a program using case statement in arduino software. the last two pictures is a copy of my program but it my program would not run. can you let me know what I\'ve done wrong
Solution
There are two sections in your code:
1) Input from serial : In setup() function, you will have to initialize serial port using
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
This statement opens the serial port & sets the data rate. This is missing in your code. So I feel that your code is not able to read the number.
2) Output on seven segment display based on input: In switch statement there is no need to add the case for \'A\', \'B\', \'C\' or \'D\'. That is not your problem statement, Your switch case should be like as below:
int off = 10;
switch(number)
{
case \'2\':
Num_write(2);
break;
case \'4\':
Num_write(4);
break;
case \'6\':
Num_write(6);
break;
case \'8\':
Num_write(8);
break;
default:
Num_write(off);
break;
}
According to above statement the Num_write() should be updated as below:
void Num_write(int number)
{
int pin=2;
for(int j=0;j<7;j++) {
if(number == off)
digitalWrite(pin, 0);
else
digitalWrite(pin, num_array[number][j]);
pin++;
}
}

