login signup | whydoineedaccount?
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <LiquidCrystal.h>
#include <Streaming.h>


LiquidCrystal lcd( 18, 11, 19, 20, 21, 22, 23 );

int status = 15;
int position = 8;
int mod = 0;
unsigned long prev = 0;

void setup( )
{
  pinMode( status, OUTPUT ); 
  digitalWrite( status, HIGH );
  Serial.begin( 9600 );
}

void loop( ) {  
  int x, y;
  
  x = analogRead( 6 );
  y = analogRead( 7 );
  
  Serial << x << " " << y << endl;
  
  if( x>y ) mod = 1;
  else if( x<y ) mod = -1;
  else mod = 0;
  
  if ( millis( ) - prev > ( 2200-x-y ) ) {
    lcd.clear( );
    
    prev = millis( );  
    position += mod;
    if( position > 16 ) position = 0;
    if( position < 0 ) position = 16;
    
    lcd.setCursor( position, 1 );
    lcd.print( "^" );
  }
  delay( 100 );
}
back to top ↑

Did you know, that…?

wklej.org it's a NoPaste site, which allows you to paste here any text, or source code, which will be available under special URL. Thanks to this, you can make forums or IRC channels more readable