Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(40, 2);
- // Print a message to the LCD.
- //lcd.print(" ");
- }
- double nap;
- int x = 5;
- int a = 5;
- int tmp = 0;
- int i;
- String s = "";
- void loop() {
- nap = analogRead(A0);
- //select = 722
- //left = 480
- //up = 131
- //down = 307
- //right = 0
- // alone = 1023
- // set the cursor to column 0, line 1
- // (note: line 1 is the second row, since counting begins with 0):
- // print the number of seconds since reset:\
- lcd.setCursor(a,0);
- lcd.print(" ");
- tmp = rand()%2;
- if(tmp == 0){
- if(a > 0){
- a--;
- }
- }else{
- if(a < 15){
- a++;
- }
- }
- lcd.setCursor(a,0);
- lcd.print("x");
- /////////////////////////////////
- lcd.setCursor(x, 1);
- lcd.print(" ");
- if(analogRead(A0) > 450 && analogRead(A0) < 510){
- if(x > 0){
- x = x-1 ;
- }
- }
- if(analogRead(A0) > -30 && analogRead(A0) < 30){
- if(x < 15){
- x = x+1 ;
- }
- }
- lcd.setCursor(x,1);
- lcd.print("*");
- delay(150);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement