first commit
This commit is contained in:
89
RAMPS_TEST_LCD/RAMPS_TEST_LCD.ino
Executable file
89
RAMPS_TEST_LCD/RAMPS_TEST_LCD.ino
Executable file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Tests de la carte ramps
|
||||
* Note: On most Arduino boards, there is already an LED on the board
|
||||
connected to pin 13, so you don't need any extra components for this example.
|
||||
|
||||
|
||||
DISPLAY ON Arduino Mega2560 VIA RAMPS
|
||||
* LCD RS pin to digital pin 16
|
||||
* LCD Enable pin to digital pin 17
|
||||
* LCD D4 pin to digital pin 23
|
||||
* LCD D5 pin to digital pin 25
|
||||
* LCD D6 pin to digital pin 27
|
||||
* LCD D7 pin to digital pin 29
|
||||
* LCD R/W pin to ground
|
||||
|
||||
|
||||
|
||||
*/
|
||||
// include the library code for LCD display:
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
// constants won't change. They're used here to
|
||||
// set pin numbers:
|
||||
const int led1 = 13; // the number of the standard led
|
||||
const int button = 41; // the number of the pushbutton pin
|
||||
const int speakerPin = 37; // buzzer connected
|
||||
|
||||
//LCD RS pin to digital pin 16
|
||||
const int lcdrs=16;
|
||||
//LCD Enable pin to digital pin 17
|
||||
const int lcde=17;
|
||||
//LCD D4 pin to digital pin 23
|
||||
const int lcdd4=23;
|
||||
//LCD D5 pin to digital pin 25
|
||||
const int lcdd5=25;
|
||||
//LCD D6 pin to digital pin 27
|
||||
const int lcdd6=27;
|
||||
//LCD D7 pin to digital pin 29
|
||||
const int lcdd7=29;
|
||||
|
||||
// say ON is alighted and OFF is not
|
||||
// led are lighted when pin is HIGH
|
||||
const int ON=HIGH;
|
||||
const int OFF=LOW;
|
||||
const int FALSE=LOW;
|
||||
const int TRUE=HIGH;
|
||||
//variable to keep state of display done
|
||||
int done=FALSE;
|
||||
// initialize the library with the numbers of the interface pins
|
||||
// create object: lcd (available as global object)
|
||||
LiquidCrystal lcd(16,17,23,25,27,29);
|
||||
|
||||
void setup() {
|
||||
pinMode(button, INPUT); // button is input
|
||||
digitalWrite(button,HIGH); // need pull up resistor: HIGH/TRUE when not activated, LOW/FALSE when activated
|
||||
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(20, 4);
|
||||
// shutdown LED
|
||||
digitalWrite(led1, OFF);
|
||||
// clear LCD display
|
||||
lcd.clear();
|
||||
// wait 2 sec
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// write once to avoid flickering of display
|
||||
if (!done) {
|
||||
lcd.clear();
|
||||
digitalWrite(led1, OFF);
|
||||
displayLcd(0,0,"hello");
|
||||
displayLcd(1,1,"salut");
|
||||
done=true;
|
||||
}
|
||||
if (!digitalRead(button)) {
|
||||
done=false;
|
||||
lcd.clear();
|
||||
delay(5);
|
||||
digitalWrite(led1, ON);
|
||||
displayLcd(0,0,"Bouton !");
|
||||
while (!digitalRead(button)) {};
|
||||
}
|
||||
}
|
||||
|
||||
void displayLcd(int c, int l, String t) {
|
||||
lcd.setCursor(c,l);
|
||||
lcd.print(t);
|
||||
}
|
||||
Reference in New Issue
Block a user