Push button Problem


hey leute,

bin noch recht neu auf dem gebiet von arduino und verzweifel zur zeit einem recht einfachen problem. möchte die anzeige vom display mit einem druck auf einen push button verändern aber leider weiss ich nicht 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:

code: [select]

#include <adafruit_gfx.h>
#include <adafruit_sharpmem.h>
#include <avr/pgmspace.h>
// pins can 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;     // number of pushbutton pin
// variables change:
int buttonstate = 0;         // variable reading pushbutton status 
};



void setup(void)
{
serial.begin(9600);
pinmode(buttonpin, input);
display.begin();
display.cleardisplay();
}


void loop(void)
{
    // read state of pushbutton value:
  buttonstate = digitalread(buttonpin);

  // check if pushbutton pressed.
  // if is, buttonstate 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 refreshed @ least once per second
display.refresh();
display.cleardisplay();
delay(500);
}

display.cleardisplay();

das ende bringt nichts! wenn überhaupt direkt anfang der loop. sinnvoll bleibt es aber nicht, sollte aber dann gehen.


Arduino Forum > International > Deutsch (Moderator: uwefed) > Push button Problem


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support