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

Problem 2.0 Write a complete program to display numbers 2,4,6,8 using CASE statement, Use the word \"number\" in your switch statement. If the number equals to 2 or 4 or 6 or 8 then display that number on the seven- segment display. Funcbion hender

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++;

}

}

 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 pr
 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 pr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site