Question

This question is about the Arduino code.

Please complete a 4-input circuit on your Arduino. Your circuit, in addition to cycling through a binary representation of the numbers 0-15 using LEDs, should use the Serial port to output the decimal equivalent of each of the numbers in the format:

Output: 15

... if the value was 1111, and so forth.

You will be asked to upload your code as well as a photo of your working breadboard circuit.

Add comments to your code as needed.

Thank you...CHAG ON ARDUINO.CC MKR 1000 Uses pins 4,5,6,7Arduino Code – using for loops Loops - • note repetitive nature of tables loop would be a natural way of organizing code • 0Arduino Code, for loops – HIGH and LOW O Idea: HIGH and LOW are constants! documentation is ambiguous, so test programmaticalArduino Code, for loops – HIGH and LOW • Result: Value of HIGH is: 1 Value of LOW is: 0 Since HIGH is 1 and LOW is 0, our ifArduino Code, for loops – println statements • In the unlooped code, we used println statements for debugging: Serial.printlnArduino Code, for loops improved! . 4-input: for (int i=0;i<=1;i++) for (int j=0; j<=1; j++) for (int k=0; k<=1; k++) for (in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*

here is the link to the code : https://create.arduino.cc/editor/rahul_agam/33976ab4-e991-4f5f-9d4c-446ae43d5081/preview

*/

// declaring pins 4,5,6,7
int led_a = 4;
int led_b = 5;
int led_c = 6;
int led_d = 7;

void setup( ) {

// declaring 4,5,6,7 as OUTPUT pins
pinMode( led_a , OUTPUT);
pinMode( led_b , OUTPUT);
pinMode( led_c , OUTPUT);
pinMode( led_d , OUTPUT);

// baudrate for serial communication as 9600
Serial.begin(9600);
  
} // END OF setup( )

void loop() {

// i refers to MSB bit
for(int i =0; i <= 1; i++) {
for(int j=0;j <= 1; j++) {
for(int k =0; k <= 1; k++) {

// ' l ' refers to LSB bit
for(int l=0; l <= 1; l++) {

// binary to decimal conversion
int decValue = i*8 + j*4 + k*2 + l*1 ;

// printing on to serial monitor
Serial.print("The value in Decimal is: ");
Serial.println(decValue);
  
if( i == 0 ){
digitalWrite(led_a, LOW );
}
else {
digitalWrite(led_a, HIGH);
}
  
if( j == 0 ){
digitalWrite(led_b, LOW );
}
else {
digitalWrite(led_b, HIGH);
}
  
if( k == 0 ){
digitalWrite(led_c, LOW );
}
else {
digitalWrite(led_c, HIGH);
}
  
if( l == 0 ){
digitalWrite(led_d, LOW );
}
else {
digitalWrite(led_d, HIGH);
}

// delay of 1 sec = 1000 milli seconds
delay(1000);
  
  
}
}
}
}

  
} // END OF Loop

---------------------------------------------------------------------------------------------------

OUTPUT :

The value in Decimal is: 0 The value in Decimal is: 1 The value in Decimal is: 2 The value in Decimal is: 3 The value in Deci

Activities Arduino IDE Oct 2 1:36 PM A /dev/ttyACMO Send Timal is: 14 mal is: 10 The value in Decimal is: 11 The value in Dec

DIGI TALCPWT (UNO Ya

Cit:::::::::: SOCO 0 X 16X1 E. 1 DIGITAL CPWM-> OO UND B 6 -10 ARDUINO 12 QNO AREF IN 250 472 ASR

=================================================================

Circuit description :

  1. I have used Arduino Uno board.
  1. 4 LED’s , each have one positive terminal and negative terminal.
  1. Connect those negative terminals ( of all 4 LED’s ) to Ground.

3.1 First , place all the 4 LED’s on bread board , then connect ground of Arduino to bread board. Make sure You connect all the negative terminals of LED’s to that ground.

  1. Connect positive terminals to arduino

4.1 Then , connect 4 the digital pin on Arduino to anyone LED positive terminal

4.2 Then , connect 5 the digital pin on Arduino to anyone LED positive terminal

4.3 Then , connect 6 the digital pin on Arduino to anyone LED positive terminal

4.4 Then , connect 7 the digital pin on Arduino to anyone LED positive terminal

  1. Upload the code to arduino IDE and dump it into Arduino board.
  1. Open Serial monitor , there you can see your output.

THANK YOU !! If you have any doubt regarding this question , please comment.

Add a comment
Know the answer?
Add Answer to:
This question is about the Arduino code. Please complete a 4-input circuit on your Arduino. Your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • void setup () Write the following code and upload it to the { Arduino, observe and...

    void setup () Write the following code and upload it to the { Arduino, observe and comment on the pinMode (8, OUTPUT); pinMode (2, INPUT); digitalWrite (8, HIGH); function of the circuit and explain how the code is working. In addition, explain how to turn ON the LED in case it is OFF. void loop () { digitalRead (2) int A if (A 0) { digitalWrite (8, LOW); void setup () Write the following code and upload it to the...

  • Mechatronics void setup () Write the following code and upload it to the { Arduino, observe...

    Mechatronics void setup () Write the following code and upload it to the { Arduino, observe and comment on the pinMode (8, OUTPUT) function of the circuit and explain how the pinMode (2, INPUT); code is working. In addition, explain how to digitalWrite (8, HIGH) turn ON the LED in case it is OFF. void loop () { digitalRead (2) int A if (A 0) { digitalWrite (8, LOW) void setup () Write the following code and upload it to...

  • I am trying to program my Arduino UNO to implement a flashing pattern with two LEDs....

    I am trying to program my Arduino UNO to implement a flashing pattern with two LEDs. When one LED is off, the other must be on. The program needs to be done in assembly. I have a working program in c++ but I need to convert it to assembly. Here is my c++ program: int led = 13; int led2 = 12; void setup() {    pinMode(led, OUTPUT); pinMode(led2, OUTPUT); } void loop() { digitalWrite(led, HIGH);    delay(1000); digitalWrite(led, LOW);...

  • Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to...

    Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to your homework program. Continually display “0123”, “4567”, “89Ab”, “cdEF” with a one second delay between each one. HINT: Expand pickNumber() to use numbers 10-15 (a-f in hex). Create new functions for a-f. (THIS IS THE CODE FROM THE HOMEWORK) /*************************************** name:Stopwatch function: you can see the number increases by one per second on the 4-digit 7-segment display. ***********************************/ //Email:[email protected] //Website:www.sunfounder.com /**************************************/ #include //the pins...

  • Design a circuit and Arduino program that accomplishes the following: An IR distance sensor will detect the presence (t...

    Design a circuit and Arduino program that accomplishes the following: An IR distance sensor will detect the presence (through waving of a hand) A H-Bridge circuit with 9V battery power will control the direction of the DC motor as described in Chapter 4 (pp. 70-79) of your textbook. When a hand is waved over the IR sensor, the motor moves in one direction (simulating opening a door). There is a 2 second pause, and then the motor moves in the...

  • Please explain to me how the following arduino code control the smart home system design below. #...

    Please explain to me how the following arduino code control the smart home system design below. #include "ESP8266.h" #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <dht.h> #define DATA_PIN 2 #define SSID       "abc" #define PASSWORD   "12345678" byte termometerLogo[8] = {     B00100,     B01010,     B01010,     B01110,     B01110,     B11111,     B11111,     B01110 }; byte humidityLogo[8] = {     B00100,     B00100,     B01010,     B01010,     B10001,     B10001,     B10001,     B01110, }; SoftwareSerial mySerial(10,11); ESP8266 wifi(mySerial); LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); dht DHT; char buffData[150]; const int...

  • I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED str...

    I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED strips and 3 - ultrasonics. I have them working independently but I need to combine the code so they work together. Here is what I have: Memory Game #define PLAYER_WAIT_TIME 2000 // The time allowed between button presses - 2s byte sequence[100]; // Storage for the light sequence byte curLen = 0; // Current length of the sequence byte inputCount =...

  • An Arduino Uno is configured with the voltage divider connected to Analog input pin AO as...

    An Arduino Uno is configured with the voltage divider connected to Analog input pin AO as shown, and the code shown below is uploaded. What happens? testCodeA Arduino 1.8.11 Hourly Build 2019/10/29 11:12 Arduino testCodeA Uno #define LED 13 to SV 130 5ks § void setup() { pinMode(LED, OUTPUT); B toap ŹR 10 Kaş void loop 1 int voltage analogRead(AO); if (voltage > 1024/2) digitalWrite(LED, HIGH); else digitalWrite(LED, LOW); HOGNO Gong Done compiling Sketch uses 778 bytes (2%) of program...

  • An Arduino Uno is configured with the voltage divider connected to Analog input pin AO as...

    An Arduino Uno is configured with the voltage divider connected to Analog input pin AO as shown, and the code shown below is uploaded. What happens? testCodeA Arduino 1.8.11 Hourly Build 2019/10/29 11:12 Arduino Uno testCodeA #define LED 13 to sv 13o 5ke & void setup() { pinMode(LED, OUTPUT); to A 10KZ Ž ŞR void loop() { int voltage-analogRead(AO); if (voltage > 1024/2) digitalWrite(LED, HIGH); else digitalWrite(LED, LOW); GND GND Done compiling Sketch uses 778 bytes (2%) of program storage...

  • -------------------------------------------------------------------------------------------------------------------------------------------- this is the code please add the missing parts (edit it) // Longer, more obvious...

    -------------------------------------------------------------------------------------------------------------------------------------------- this is the code please add the missing parts (edit it) // Longer, more obvious example for Arduino 7 segment display // http://www.hacktronics.com/Tutorials/arduino-and-7-segment-led.html // License: http://www.opensource.org/licenses/mit-license.php (Go crazy) void setup() {                pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); digitalWrite(9, 0); // start with the "dot" off } void loop() { { // write '9' digitalWrite(2, 1); digitalWrite(3, 1); digitalWrite(4, 1); digitalWrite(5, 0); digitalWrite(6, 0); digitalWrite(7, 1); digitalWrite(8, 1); delay(1000);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT