Question

In: Electrical Engineering

Write code using the Arduino IDE that compiles with no errors. 2-bit adder: The code must...

Write code using the Arduino IDE that compiles with no errors.

2-bit adder: The code must read two digital input signals and turn on two LEDS as needed to show the sum of the inputs. e.g. 0 + 1 = 01.

Solutions

Expert Solution

Arduino code:-

int b=0;

int a=0;

const int input1 = 2;
const int input2 =3;
const int ledPin1 = 7;
const int ledPin2 = 8;


void setup()
{
  
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(input1, INPUT);
pinMode(input2, INPUT);
  
}

void loop() {

b = digitalRead(input2);
a= digitalRead(input1);

if (a==LOW && b== LOW) {
  
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
  
else if (a== LOW && b== HIGH) {
  
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
}
else if (a== HIGH && b== LOW) {

digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
}
else if (a== HIGH && b== HIGH) {
  
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
}
  
}

Done compiling without compilation errors:


Related Solutions

Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Write code in C language in the Arduino IDE ADC data using Serial plotter Serial plot...
Write code in C language in the Arduino IDE ADC data using Serial plotter Serial plot : raw data, delay data (int) Purpose: Delay Block (**Using Class**) Input : u(t) Output : o(t)=u(t-h) sample time=0.02 Delay (h) = 0.4
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using full adder that is coded using data flow model. Use test bench to test 8-bit adder and consider at least five different test vectors to test it.
I am trying to write the code for an 8 bit adder in VHDL so that...
I am trying to write the code for an 8 bit adder in VHDL so that I can program it onto my Elbert V2 Spartan 3A FPGA Development Board, but I keep getting errors. Any ideas what I am doing wrong? library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity adder8bit is Port ( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cin : in STD_LOGIC; o : out STD_LOGIC_VECTOR(7 downto 0); cout : out STD_LOGIC); end adder8bit; architecture Behavioral...
Using the following VHDL code for an 8 bit adder, make the sum be displayed on...
Using the following VHDL code for an 8 bit adder, make the sum be displayed on the seven segment display of an Elbert V2 Spartan 3A FPGA Board. VHDL: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity state_bit_adder is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC;            D : in STD_LOGIC;            Enable : out STD_LOGIC_vector (2 downto 0);            input: in std_logic_vector(7 downto 0);            SUM: out...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only available building block is a full adder. Thank
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT