Arduino Projects Experiments Part7
Arduino Projects Experiments Part7
Arduino Projects Experiments Part7
a;
b;
c;
d;
123
void setup() {
lcd.begin(16,2);
lcd.setCursor(0,0);
clearLCD();
backlightOn();
lcd.print("HELLO, WORLD!");
delay(Xdelay);
}
void loop()
{
char databuff[16];
char dispbuff[16];
// display on/off test
for(int x = 5; x>0; x--)
{
delay(1000);
displayOff();
delay(1000);
displayOn();
}
clearLCD();
backlightOn();
lcd.print("SLOW FADE
fadeOut(100);
fadeIn(10);
");
lcd.print("0123456789abcdef");
delay(Xdelay);
lcd.print("ghijklmnopqrstuv");
delay(Xdelay);
lcd.print("wxyz +?*&%$#()!=");
delay(Xdelay);
lcd.print("
");
delay(Xdelay);
lcd.print("
");
delay(Xdelay);
a
b
c
d
124
=
=
=
=
"0123456789abcdef";
"ghijklmnopqrstuv";
"wxyz +?*&%$#()!=";
"
";
selectLineTwo();
lcd.print(a);
delay(Xdelay);
selectLineOne();
lcd.print(a);
selectLineTwo();
lcd.print(b);
delay(Xdelay);
selectLineOne();
lcd.print(b);
selectLineTwo();
lcd.print(c);
delay(Xdelay);
selectLineOne();
lcd.print(c);
selectLineTwo();
lcd.print(d);
delay(Xdelay);
selectLineOne();
lcd.print(d);
selectLineTwo();
lcd.print(d);
delay(Xdelay);
125
void selectLineOne()
{
lcd.write(0xFE);
//command flag
lcd.write(128);
//position
delay(10);
}
void selectLineTwo()
{
lcd.write(0xFE);
//command flag
lcd.write(192);
//position
delay(10);
}
void goTo(int position)
{
if (position<16)
{
lcd.write(0xFE);
//command flag
lcd.write((position+128));
//position
}else if (position<32)
{
lcd.write(0xFE);
//command flag
lcd.write((position+48+128));
//position
} else { goTo(0); }
delay(10);
}
void clearLCD()
{
lcd.write(0xFE);
lcd.write(0x01);
delay(10);
}
void backlightOn()
{
lcd.write(0x7C);
lcd.write(157);
delay(10);
}
void backlightOff()
{
lcd.write(0x7C);
lcd.write(128);
delay(10);
}
//command flag
//clear command
126
void displayOn()
{
lcd.write(0xFE);
lcd.write(0x0C);
delay(10);
}
//command flag
//clear command
void displayOff()
{
lcd.write(0xFE);
lcd.write(0x08);
delay(10);
}
//command flag
//clear command
129
Figure 15-2. Fritzing diagram for a logic tester with an RGB LED
133
136
138
+5V source, as shown in Figure 16-3. Impress the local Makerspace by testing Arduino and digital electronic circuits with your Logic Tester!
Example 16-1. The Logic Tester sketch
/*
Logic Tester
LCD displays "HIGH (1)" when digital circuit signal is +5V. A "LOW (0)"
is displayed when digital circuit signal is OV.
27 April 2013
Don Wilcher
*/
// include the LCD library code:
#include <LiquidCrystal.h>
// set up pins on Arduino for LCD and transistor lead:
LiquidCrystal lcd(12,11,5,4,3,2);
int xistorPin = 6;
int digitalStatus = 0;
// variable for reading the digital circuit state
// initialize the transistor pin as an input and set up the LCD's number
// of columns and rows:
void setup() {
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("LOGIC TESTER");
pinMode(xistorPin, INPUT);
}
void loop() {
// check if digital signal is HIGH or LOW:
digitalStatus = digitalRead(xistorPin);
if (digitalStatus == HIGH) {
// if digital circuit signal is +5V, display HIGH (1):
lcd.setCursor(0,1);
lcd.print("HIGH (1) "); // display HIGH (1)
}
else {
// if digital circuit signal is 0V, display LOW (0):
lcd.setCursor(0,1);
lcd.print(" LOW (0) ");
}
}