Advertisement
apl-mhd

IoT_UIU_ICM

Oct 16th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.44 KB | None | 0 0
  1. /*United International University
  2.  Team Name:ICM..(Please never want to know what is ICM)
  3. pin 13 = light
  4.  
  5. */
  6.  
  7. int led1 = 13; //connection of pin no. 13
  8. int led2 = 12; //connection of pin no. 12
  9. int led3 = 8; //connection of pin no. 8
  10. int gate_input;
  11. char state;
  12. int fan = 9; //connection of pin no.9.... (if control regulating then must be use just only 3,5,6,9,10,11 no pin.. other pin not working for fan or light regulating)
  13. int brightness = 0;
  14.  
  15.  
  16.  
  17. void setup() {                
  18.  
  19.  pinMode(led1, OUTPUT);
  20.  pinMode(led2, OUTPUT);
  21.  pinMode(fan, OUTPUT);
  22.  
  23.  
  24.   Serial.begin(9600);
  25. }
  26.  
  27. void loop() {
  28.   if(Serial.available() > 0){    
  29.       state = Serial.read();
  30.  
  31.  
  32. //for button 1
  33.   if (state == 'a') { //android apps send a text and bluetooth module receive a text
  34.       digitalWrite(led1, HIGH);}  //switch on
  35.  
  36.   if (state == 'b') { //android apps send b text and bluetooth module receive b text
  37.       digitalWrite(led1, LOW);}  //switch off
  38.      
  39.      
  40.       //for button 2
  41.   if (state == 'c') { //android apps send c text and bluetooth module receive c text
  42.       digitalWrite(led2, HIGH);}  //switch on
  43.  
  44.   if (state == 'd') {  //android apps send d text and bluetooth module receive d text
  45.       digitalWrite(led2, LOW);} //switch off
  46.      
  47.      
  48.            //for button 3
  49.   if (state == 'e') { //android apps send e text and bluetooth module receive e text
  50.       digitalWrite(led3, HIGH);}  //switch on
  51.  
  52.   if (state == 'f') { //android apps send f text and bluetooth module receive f text
  53.       digitalWrite(led3, LOW);} //switch off
  54.      
  55.      
  56.      
  57.          
  58.       /*******************************for fan control************************/
  59.      
  60.   if (state == 'm') { //android apps send m text and bluetooth module receive m text
  61.    
  62.    analogWrite(fan, 255);  
  63.  }
  64.      
  65.  
  66.   if (state == 'n') {   //android apps send n text and bluetooth module receive n text
  67.       analogWrite(fan, 192);}
  68.        
  69.        if (state == 'o') {  //android apps send o text and bluetooth module receive o text
  70.    
  71.    analogWrite(fan, 129);  
  72.  }
  73.   if(state == 'p'){  //android apps send p text and bluetooth module receive p text
  74.    
  75.       analogWrite(fan, 66);
  76.     }
  77.  
  78.   if(state == 'q'){   //android apps send q text and bluetooth module receive q text
  79.       analogWrite(fan, LOW); //switch off
  80.     }  
  81.    
  82.     /* end fan */
  83.  
  84.  
  85.  
  86.     }
  87.        //for pump
  88.  
  89.      
  90.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement