Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. // initialize the library with the numbers of the interface pins
  4. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  5.  
  6. void setup() {
  7. // set up the LCD's number of columns and rows:
  8. lcd.begin(40, 2);
  9. // Print a message to the LCD.
  10. //lcd.print(" ");
  11. }
  12.  
  13. double nap;
  14. int x = 5;
  15. int a = 5;
  16. int tmp = 0;
  17. int i;
  18. String s = "";
  19. void loop() {
  20. nap = analogRead(A0);
  21. //select = 722
  22. //left = 480
  23. //up = 131
  24. //down = 307
  25. //right = 0
  26. // alone = 1023
  27. // set the cursor to column 0, line 1
  28. // (note: line 1 is the second row, since counting begins with 0):
  29.  
  30. // print the number of seconds since reset:\
  31.  
  32. lcd.setCursor(a,0);
  33. lcd.print(" ");
  34. tmp = rand()%2;
  35. if(tmp == 0){
  36. if(a > 0){
  37. a--;
  38. }
  39. }else{
  40. if(a < 15){
  41. a++;
  42. }
  43. }
  44. lcd.setCursor(a,0);
  45. lcd.print("x");
  46.  
  47.  
  48.  
  49. /////////////////////////////////
  50. lcd.setCursor(x, 1);
  51. lcd.print(" ");
  52. if(analogRead(A0) > 450 && analogRead(A0) < 510){
  53. if(x > 0){
  54. x = x-1 ;
  55. }
  56. }
  57. if(analogRead(A0) > -30 && analogRead(A0) < 30){
  58. if(x < 15){
  59. x = x+1 ;
  60. }
  61. }
  62. lcd.setCursor(x,1);
  63. lcd.print("*");
  64.  
  65. delay(150);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement