/***********************************************************************************
DATE 17 DEC 2022
LCD2004 MESSAGE
this project is showing how to display information on lcd (20,4)
also inclide chasing led code 2
THERE ARE THREE STAGES OF CODING
1 DEFINES/INCLUDE LIABRARIES
2 VOIDE SETUP
3 VOIDE LOOP
TREATTHE BIG CODE AS CODE ONE CPOY AND PAST THE RESPECTIVE STAGES OF CODE 2 TO CODE ONE
CONECTS THE HARDWARE
ORIGINAL CODE
***********************************************************************************/
//cpoed from code2
int pinsCount=11; // declaring the integer variable pinsCount
int pins[] = {2,3,4,5,6,7,9,10,11,12,13}; // declaring the array pins[]
#include <LiquidCrystal.h>
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
//combined void setup
void setup() {
Serial.begin(9600);
lcd.begin(20, 4);
lcd.println(" Hello World!");
Serial.print("hello world");
lcd.setCursor(1, 1);
lcd.print("ACtivity 3");
lcd.setCursor(1, 2);
lcd.print("LED Pattern");
lcd.setCursor(1, 3);
lcd.println("Binary Counter");
delay(2000);
lcd.noDisplay();
delay(2000);
//copied from code 2
for (int i=0; i<pinsCount; i=i+1){ // counting the variable i from 0 to 7
pinMode(pins[i], OUTPUT); // initialising the pin at index i of the array of pins as OUTPUT
}
}
void loop() {
delay(500); // turn off the blinking cursor:
lcd.blink(); // turn on the blinking cursor
delay(500);
for (int i=0; i<256; i=i+1){
Serial.println(i);
byte a = i%2;
byte b = (i/2)%2;
byte c = (i/4)%2;
byte d = (i/8)%2;
byte e = (i/16)%2;
byte f = (i/32)%2;
byte g = (i/64)%2;
byte h = (i/128)%2;
digitalWrite(3, a);
digitalWrite(4, b);
digitalWrite(5, c);
digitalWrite(6, d);
digitalWrite(7, e);
digitalWrite(10, f);
digitalWrite(11, g);
digitalWrite(12, h);
delay(500);
}
}