Advertisement
Guest User

Untitled

a guest
Oct 24th, 2020
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //---------ELECTRONOOBS----------//
  2. //--------BT app control---------//
  3.  
  4.  
  5. int lamp=11;
  6. int vent=11;
  7. int light=11;
  8. int pc=11;
  9.  
  10. int Received=0;
  11. int light_state =0;
  12. int vent_state = 0;
  13. int pc_state = 0;
  14.  
  15.  
  16. void setup(){
  17.  
  18. Serial.begin(9600);
  19. pinMode(lamp,OUTPUT);
  20. pinMode(vent,OUTPUT);
  21. pinMode(light,OUTPUT);
  22. pinMode(pc,OUTPUT);
  23.  
  24. }
  25.  
  26. void loop(){
  27.  
  28. if(Serial.available()>0)
  29. {
  30. Received = Serial.read();
  31.  
  32. }
  33. ////////////////LIGHT/////////////////////
  34. if (light_state == 0 && Received == '1')
  35. {
  36. digitalWrite(light,HIGH);
  37. light_state=1;
  38. Received=0;
  39. }
  40. if (light_state ==1 && Received == '1')
  41. {
  42. digitalWrite(light,LOW);
  43. light_state=0;
  44. Received=0;
  45. }
  46. ///////////////////////////////////////////
  47.  
  48.  
  49.  
  50. ////////////////VENT/////////////////////
  51. if (vent_state == 0 && Received == 'a')
  52. {
  53. digitalWrite(vent,HIGH);
  54. vent_state=1;
  55. Received=0;
  56. }
  57. if (vent_state ==1 && Received == 'a')
  58. {
  59. digitalWrite(vent,LOW);
  60. vent_state=0;
  61. Received=0;
  62. }
  63. ///////////////////////////////////////////
  64.  
  65.  
  66.  
  67.  
  68. ////////////////PC/////////////////////
  69. if (pc_state == 0 && Received == '2')
  70. {
  71. digitalWrite(pc,HIGH);
  72. pc_state=1;
  73. Received=0;
  74. }
  75. if (pc_state ==1 && Received == '2')
  76. {
  77. digitalWrite(pc,LOW);
  78. pc_state=0;
  79. Received=0;
  80. }
  81. ///////////////////////////////////////////
  82.  
  83.  
  84.  
  85.  
  86.  
  87. ////////////////LAMP/////////////////////
  88. if (Received =='8'){
  89. digitalWrite(lamp,HIGH);
  90. }
  91. if (Received == '9'){
  92. digitalWrite(lamp,LOW);
  93. }
  94. ///////////////////////////////////////////
  95.  
  96.  
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement