michelesmith7151 michelesmith7151
  • 25-11-2020
  • Computers and Technology
contestada

Write modified code that will generate a random number between 0 and 255 when a button is pressed and will write the number to the serial monitor as well as to the receiver Arduino.

Respuesta :

AbsorbingMan AbsorbingMan
  • 26-11-2020

Solution :

#include<LiquidCrystal.h>

int value;

int flag;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

{

lcd.begin(16, 2);

Serial.begin(9600);

}

void loop()

{

value=digitalRead(7);

  if(value==0){

flag=1;}

  if(value==1){

flag=~flag;}

  if (flag==1){

lcd.setCursor(0,0);    

  lcd.print("number is");

lcd.setCursor(2,1);    

lcd.print(random(0, 255));

delay(1000);

}

  else{

lcd.setCursor(0,0);

lcd.print("Not Pressed");

delay(1000);

lcd.clear();}

}

Answer Link

Otras preguntas

what are they 1.) input devices2.) output devices3.) processing devices can you please answer  all of them please.
Renuka has two pounds of pepper in her cupboard. She knows that there are 16 ounces in one pound. After Renuka makes one batch of Garam Masala, how many ounces
a giraffe can run up to 46.93 feet per second. how far can a giraffe run in 1.8 seconds. justify your answer
What percentage is £95 of £250?
What is one tenth of 80
what is the mathematical name for a diamond (quadrilateral)
Round 111.11111 to the nearest ten thousandth.
a student measures the mass of an 8cm block of brown sugar to be 12.9g. what is the density of the brown sugar
Keith and Michelle went out to dinner. The total cost of the meal, including the tip, came to $53.70. If the combined tip came out to $9.60, and each friend spe
Where did jazz originate?