Write a program which reads the four buttons on the Arduino.

Write a program which reads the four buttons on the Arduino. Treat the four buttons as bits in an input, with the right most button being the 0th place. Print this value as a number of asterisks ‘*’ entered on the switches to the serial console (for example, if the value of the four switches calculates to 5, “*****” should be printed to the serial.console). If the value is 7, play a tone on the speaker. If the value is a multiple of two and not zero, light the RED LED. If the value is a multiple of three, light the GREEN LED. If the value is odd, light the BLUE LED. If the value is prime, light the laser (be sure to handle 1 correctly). Resample the switches and change the output every half second (ignoring processing time).

Hints: partition up the problem. Create subroutines to:

• Read the four switches and return the unsigned integer which is their value • Print this value to the serial console • Act on this value

Follow the process:

• List the inputs & outputs

• Design an algorithm to solve this problem in either pseudocode or with a flowchart (2 point extra for a good flowchart)

• Verify the algorithm works

• Write the program

• Test the program with all inputs and verify that it is working.

 
"Looking for a Similar Assignment? Order now and Get 10% Discount! Use Code "Newclient"