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

A sequence is defined by the term-to-term rule Un+1=U₁+3 Given that u,= 1, a) find u₁ b) find u₂ c) find u₁
I dont understand this at all so here is 100 points
Find the unknown length y in the pair of similar triangles. 33 ft 9 ft 21 ft y
2115536 (3) Co 40 (6) 71 Go 25 20 ५० Jrl8 25
If point m maps to point m' what will the relationship between 0m and 0m' be?
Which statement most clearly describes Martin in the early part of the "The Medicine Bag"?
Identify one cause of Western Europeans traveling to fight in the Crusades.
Francis bought 5 holiday gifts that were between $42 and $87. What is a reasonable amount that he paid for the items?
Task: restate the Question ,, 'why is sleep so important ' ?
1. Han's teacher asked him to draw a polygon similar to polygon A. Here is his work. Which explanation shows that polygons A and C are similar to each other? A