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

Self-confidence is the most important quality for A. consideration. B. communication. C. building new relationships. D. good listening skills.
The part of the brain which controls breathing and heartbeat is the .
The GDP is $123.7 billion. The population is 4 million. Find the per capita GDP.
why was the fate of the middle east up in the air toward the end of WW1
How do evaporation and condensation relate to heat
what is the value of 3 in 23
why do you believe beatty programmed the hound to track montag even before the stolen book? do you believe beatty had seen him steal books before? or is it that
The naturalization process involves several steps including
The diagonal of a tv is 28 inches long. Assuming that this diagonal forms a pair of 30-60-90 right triangles, what are the exact length and width of the tv?
State why are parthenogenesis is considered a form of asexual reproduction.