The Mind Reading Arduino


hello,

first post 33 year old electronics newbie. bought arduino starting kit summer , trying learn how these things work. have programmed games , applications 25 years, hobby, it's time!

yesterday saw interesting video mind , today did small experiment it. here is, mind reading arduino:

code: [select]

int lightpin = 2; // connect led pin 2
int buttonpin = 3; // connect push button pin 3

int previous = low;
int maxdelay = 200;
int mindelay = 1;
int delaytime = maxdelay;
int lighton = 250;
int presses = 0;
int maxpresses = 8;

void setup() {
  pinmode( lightpin, output );
  pinmode( buttonpin, input );
}

void loop() {
  int reading = digitalread( buttonpin );
  if( reading != previous && reading == high ) {
    onpress();     
  }
  previous = reading; 
}

void onpress() {
  if( ++presses >= maxpresses ) {
    delaytime = mindelay; 
    presses = 0;
  } 

  delay( delaytime );
  delaytime = maxdelay; // reset
  digitalwrite( lightpin, high );
 
  delay(lighton);
  digitalwrite( lightpin, low );
}


led pin 2, push button pin 3.
boot up. @ led , press button bunch of times.
sometimes led turn on juuust before press button! (or seems)

just silly little thing did in order hello.
(please forgive me if posted in wrong place. based on dorum descriptions 1 seemed appropriate.)



Arduino Forum > Community > Exhibition / Gallery > The Mind Reading Arduino


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