Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <LedControl.h>
  2.  
  3. int DIN = 12;
  4. int CS = 10;
  5. int CLK = 11;
  6.  
  7.  
  8. int row=0;
  9. int col=0;
  10. int temp=0;
  11. int data=0;
  12.  
  13. LedControl lc=LedControl(DIN,CLK,CS,1);
  14.  
  15. void setup()
  16. {
  17. lc.shutdown(0,false);
  18. lc.setIntensity(0,5);
  19. lc.clearDisplay(0);
  20. Serial.begin(9600);
  21. }
  22.  
  23.  
  24.  
  25.  
  26. void loop()
  27. {
  28. if(Serial.available() > 0)
  29. {
  30. data = Serial.read();// it returns ascii value if we send one in the phone
  31. if(data < 96)
  32. {
  33. if(temp==0)
  34. {
  35. row=data-48;
  36. temp=1;
  37. }
  38. else
  39. col=data-48;
  40. }
  41.  
  42. else if(data=='n')
  43. {
  44. lc.setLed(0,row,col,true);
  45. Serial.println('n');
  46. Serial.println(row);
  47. Serial.println(col);
  48. temp=0;
  49. }
  50. else if(data=='f')
  51. {
  52. lc.setLed(0,row,col,false);
  53. Serial.println('f');
  54. Serial.println(row);
  55. Serial.println(col);
  56. temp=0;
  57. }
  58.  
  59. else if(data=='r')
  60. lc.clearDisplay(0);
  61. }
  62.  
  63.  
  64. }
Add Comment
Please, Sign In to add comment