Question

In: Computer Science

Arduino Project - Part 1 • Connect 3 LEDs on 3 digital pins • Blink LEDs...

Arduino Project -

Part 1

• Connect 3 LEDs on 3 digital pins

• Blink LEDs at: – 1 at 1 Hz – 2 at 4 Hz – 3 at 5 Hz

• Blink LEDs at: – 1 Hz – 3 Hz – 5 Hz 36

What to submit

• 2 Arduino files – one for 1,4,5 Hz blinking – one for 1,3,5 Hz blinking

Solutions

Expert Solution

ANSWER:

  • I have provided the properly commented code in both text and image format so you can easily copy the code as well as check for correct indentation.
  • I have provided the output image of the code so you can easily cross-check for the correct output of the code.
  • Have a nice and healthy day!!

CODE TEXT

  • CODE 1(for 1,4,5 Hz blinking)

/*CODE 1-
Blink LEDs at: – 1 at 1 Hz – 2 at 4 Hz – 3 at 5 Hz*/

// Pin 2, 3, 4 has an LED connected
// defining led pins
int led1 = 2;
int led1 = 3;
int led1 = 4;

// defining the setup routine
void setup() {
// initialize the digital pins as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}

// defining the loop routine
void loop() {
/*Blinking Logic
For 1Hz- LED becomes High and LOW once in a second so 500ms for every state
For 4Hz- LED becomes High and LOW four times in a second so 125ms for every state
For 5Hz- LED becomes High and LOW five times in a second so 100ms for every state
  
As all three proccess has to be implemented synchronously in a second, defining a algo,
HCF of 100, 125 and 500 is => 25
if 25*(Multiple of 4) => LED3 State changes
if 25*(Multiple of 5) => LED2 State changes
if 25*(Multiple of 20) => LED1 State changes
*/
// initially turning all LEDs HIGH
digitalWrite(led1, HIGH); // LED1 HIGH
digitalWrite(led2, HIGH); // LED2 HIGH
digitalWrite(led3, HIGH); // LED3 HIGH
// for loop 40 times with delay of 25 ms to complete a second
for(i =1;i<=40;i++){
// delaying for 25 ms
delay(25);
// checking for counter multiples
// for LED1
if(i%20==0){
// changing state of LED1
digitalWrite(led1, !digitalRead(led1));
}
// for LED2
if(i%5==0){
// changing state of LED2
digitalWrite(led2, !digitalRead(led2));
}
// for LED3
if(i%4==0){
// changing state of LED3
digitalWrite(led3, !digitalRead(led3));
}
}
}

  • CODE 2(for 1,3,5 Hz blinking)

/*CODE 2-
Blink LEDs at: – 1 at 1 Hz – 2 at 3 Hz – 3 at 5 Hz*/

// Pin 2, 3, 4 has an LED connected
// defining led pins
int led1 = 2;
int led1 = 3;
int led1 = 4;

// defining the setup routine
void setup() {
// initialize the digital pins as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}

// defining the loop routine
void loop() {
/*Blinking Logic
For 1Hz- LED becomes High and LOW once in a second so 500ms for every state
For 3Hz- LED becomes High and LOW four times in a second so 166ms for every state
For 5Hz- LED becomes High and LOW five times in a second so 100ms for every state
  
As all three proccess has to be implemented synchronously in a second, defining a algo,
HCF of 100, 166 and 500 is => 2
if 2*(Multiple of 50) => LED3 State changes
if 2*(Multiple of 83) => LED2 State changes
if 2*(Multiple of 250) => LED1 State changes
*/
// initially turning all LEDs HIGH
digitalWrite(led1, HIGH); // LED1 HIGH
digitalWrite(led2, HIGH); // LED2 HIGH
digitalWrite(led3, HIGH); // LED3 HIGH
// for loop 500 times with delay of 2 ms to complete a second
for(i =1;i<=500;i++){
// delaying for 2 ms
delay(2);
// checking for counter multiples
// for LED1
if(i%250==0){
// changing state of LED1
digitalWrite(led1, !digitalRead(led1));
}
// for LED2
if(i%83==0){
// changing state of LED2
digitalWrite(led2, !digitalRead(led2));
}
// for LED3
if(i%50==0){
// changing state of LED3
digitalWrite(led3, !digitalRead(led3));
}
}
}


CODE IMAGE

  • CODE 1(for 1,4,5 Hz blinking)

  • CODE 2(for 1,3,5 Hz blinking)


Related Solutions

Make a circuit with a Arduino that: • Has 2 digital pins, each pin connects to...
Make a circuit with a Arduino that: • Has 2 digital pins, each pin connects to the base of a transistor, which then acts as a switch to turn on/off the LED • Connect a DC motor directly to the Arduino. Include Pictures of your circuit please.
Try to control 3 LEDs by Potentiometer. Take 3 LEDs and connect it up the same...
Try to control 3 LEDs by Potentiometer. Take 3 LEDs and connect it up the same way we use to do and connect the potentiometer to one of the analog pins. Observe the values coming out from it. Program the code such a way, when it runs, first, LED 1 should turn ON, then after a certain amount of value range, LED 1 should be OFF and LED 2 should be ON. Again, the same way, LED 2 should be...
Build a circuit for arcade game. You have 3 LEDS and 1 button. the LEDs should...
Build a circuit for arcade game. You have 3 LEDS and 1 button. the LEDs should recycle through 000,100,110,111,011, 001(back to 000). The user needs to hit the button during the 111 cycle 3 times in a row to win. The win is shown as an LED which is HIGH if the user won the last attempt of 3 presses. The win LED will be LOW otherwise
FOR ARDUINO PROGRAMMING; WRITE CODE TO FIT THE BELOW REQUIREMENTS 1. LED 3 TURNS ON IN...
FOR ARDUINO PROGRAMMING; WRITE CODE TO FIT THE BELOW REQUIREMENTS 1. LED 3 TURNS ON IN DARK CONDITIONS AND OFF IN LIGHT CONDITIONS 2. LED 4 TURNS ON WITH FIRST BUTTON PRESS AND STAYS ON UNTIL A SECOND BUTTON PRESS
Strategic Management Section 1 = Part 3 of project Consider the same company ‘Apple’ in the...
Strategic Management Section 1 = Part 3 of project Consider the same company ‘Apple’ in the following questions. Evaluate the performance of the main activity of your selected company (performance of principal product/service). What type(s) of criteria do you use to evaluate this performance? (2 marks) What type(s) of control of employees and production processes is/are used by your selected company? (1.5 mark) How does the corporation manage the environmental risks? (2 marks) Evaluate the competitive advantage of the corporation...
Question 3 (12 marks) Part A ( 3 marks) A project (by a competitor) is way...
Question 3 Part A ( 3 marks) A project (by a competitor) is way behind development by five months. Your company's Project Manager Ellie suggested using the "exploit" strategy to supply to the customer. Explain to your team briefly what is this type of risk? Part B ( 9 marks) With reference to the strategy of exploitation above, now create a detailed plan on what you would execute with your team. [Assumption: Budget is not a problem.]
Part 1 How did Barack Obama’s presidential campaigns connect with the history of American freedom? What...
Part 1 How did Barack Obama’s presidential campaigns connect with the history of American freedom? What are some specific examples that demonstrate the connections? Part 2 Discuss women journey through the late 1800s to the present day. Discuss how their freedoms have expanded or contracted through at least 3 distinct events of American history (war, depression, protest, social conflict, elections, etc). In your response, please provide your definition of freedom and clearly identify how the group of people you are...
ACC 3010 Project 3 Part 1 Complete the attached Depreciation Schedules for each of the planned...
ACC 3010 Project 3 Part 1 Complete the attached Depreciation Schedules for each of the planned asset purchases using the provided information regarding cost, useful life, and selected method. You should do only the first 4 years for the building and do the complete useful life depreciation schedules for all of the other assets. *SHOW WORK FOR ALL CALCULATIONS PLANNED ASSET ACQUISITIONS Reminder that the company’s fiscal year is July 1 through June 30. Asset Cost Useful life Salvage Value...
Need this Part 3 Answered. Part 1 is attached as well. 5–C. Part 3. New Debt...
Need this Part 3 Answered. Part 1 is attached as well. 5–C. Part 3. New Debt Service Fund Transactions On the advice of the city attorney, a City Jail Debt Service Fund is opened to account for debt service transactions related to the bond issue sold on January 1, 2017 (see Part 1). Required: a. Open a general journal for the City Jail Debt Service Fund. Record the following transactions, as necessary. Control accounts are not necessary (1) The premium...
Cost Accounting Project Part I Template Project Part I 1 An overview of the job-costing system...
Cost Accounting Project Part I Template Project Part I 1 An overview of the job-costing system is: 2 Budgeted manufacturing overhead divided by allocation base: a. Machining Department: b. Finishing Department: Show work 3 Machining Department overhead Finishing Department overhead Total manufacturing overhead allocated $0 4 Total costs of Job 431: Direct costs: Show work Direct materials Machining Department Finishing Department Direct manufacturing labor Machining Department Finishing Department 0 Indirect costs: Machining Department overhead Finishing Department overhead 0 Total costs...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT