Hey Leute,
bin noch recht neu auf dem Gebiet von Arduino und verzweifel zur Zeit an einem recht einfachen Problem. Möchte die Anzeige vom Display mit einem Druck auf einen Push button verändern aber leider weiss ich nicht was ich genau wie ich dieses Tutorial abändern muss: http://www.arduino.cc/en/Tutorial/Pushbutton .Wäre super dankbar wenn mir jemand helfen könnte.
Mein Setup:
-Arduino Pro micro 3,3V 8Mhz
-Sharp Memory LCD für Anzeige
-Push sowie 4,7 Kohm Widerstand zwischen Pin 2 und VCC (irgenwo muss ich doch noch hier mit Ground verbinden oder???)
Mein Code bisher:
#include <Adafruit_GFX.h>
#include <Adafruit_SharpMem.h>
#include <avr/pgmspace.h>
// any pins can be used
#define SCK 10
#define MOSI 16
#define SS 14
Adafruit_SharpMem display(SCK, MOSI, SS);
#define BLACK 0
#define WHITE 1
const int buttonPin = 2; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
};
void setup(void)
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
display.begin();
display.clearDisplay();
}
void loop(void)
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
//Text 1
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,2);
display.println("Hello World");
}
else {
//Text 2
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,2);
display.println("Text 2");
}
//Screen must be refreshed at least once per second
display.refresh();
display.clearDisplay();
delay(500);
}