SHARE
TWEET

Untitled

a guest Sep 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #include <SPI.h>
  2.     #include <ESP8266WiFi.h>
  3.  
  4.    
  5.     // color swirl! connect an RGB LED to the PWM pins as indicated
  6.     // in the #defines
  7.     // public domain, enjoy!
  8.      
  9.     #define REDPIN 16
  10.     #define GREENPIN 5
  11.     #define BLUEPIN 4
  12.      
  13.     #define FADESPEED 1000     // make this higher to slow down
  14.  
  15.     //SSID of your network
  16.     char ssid[] = "LIGHTPHOTO";
  17.     //password of your PA Network
  18.     char pass[] = "22264596";
  19.  
  20.     void setup() {
  21.       // put your setup code here, to run once:
  22.       Serial.begin(9600);
  23.  
  24.       WiFi.begin(ssid, pass);
  25.  
  26.       Serial.print("Connecting");
  27.       while(WiFi.status() != WL_CONNECTED){
  28.         Serial.print(".");
  29.         red();
  30.         delay(1000);
  31.       }
  32.       pinMode(REDPIN, OUTPUT);
  33.       pinMode(GREENPIN, OUTPUT);
  34.       pinMode(BLUEPIN, OUTPUT);
  35.  
  36.       Serial.println();
  37.     }
  38.      
  39.      
  40.     void loop() {
  41.       long rssi = WiFi.RSSI();
  42.       Serial.print("RSSI: ");
  43.       Serial.println(rssi);
  44.      
  45.     if(WiFi.status() != WL_CONNECTED){
  46.         blue();
  47.     }else{
  48.       if(rssi >= -60){
  49.         darkgreen();
  50.       }else if(rssi <= -61 && rssi >= -70){
  51.         lightgreen();
  52.       }else if(rssi <= -71 && rssi >= -80){
  53.         yellow();
  54.       }else if(rssi <= -81 && rssi >= -90){
  55.         orange();
  56.       }else if(rssi <= -91){
  57.         red();
  58.       }
  59.     }
  60.       delay(5000);
  61.     }
  62.  
  63.    
  64.     int blue(){
  65.        //biru
  66.         int r=0, g=0, b=1023;
  67.         analogWrite(REDPIN, r);
  68.         analogWrite(BLUEPIN, b);
  69.         analogWrite(GREENPIN, g);
  70.         delay(FADESPEED);
  71.       }
  72.      
  73.     int red(){
  74.        //merah
  75.         int r=1023, g=0, b=0;
  76.         analogWrite(REDPIN, r);
  77.         analogWrite(BLUEPIN, b);
  78.         analogWrite(GREENPIN, g);
  79.         delay(FADESPEED);
  80.       }
  81.  
  82.     int darkgreen(){
  83.        //hijau gelap
  84.         int r=0, g=120, b=1023;
  85.         analogWrite(REDPIN, r);
  86.         analogWrite(BLUEPIN, b);
  87.         analogWrite(GREENPIN, g);
  88.         delay(FADESPEED);
  89.       }
  90.  
  91.       int orange(){
  92.        //orange
  93.         int r=255, g=25, b=0;
  94.         analogWrite(REDPIN, r);
  95.         analogWrite(BLUEPIN, b);
  96.         analogWrite(GREENPIN, g);
  97.         delay(FADESPEED);
  98.       }
  99.  
  100.       int yellow(){
  101.        //kuning
  102.         int r=255, g=240, b=0;
  103.         analogWrite(REDPIN, r);
  104.         analogWrite(BLUEPIN, b);
  105.         analogWrite(GREENPIN, g);
  106.         delay(FADESPEED);
  107.       }
  108.  
  109.      
  110.       int lightgreen(){
  111.        //hijau tua
  112.         int r=0, g=255, b=15;
  113.         analogWrite(REDPIN, r);
  114.         analogWrite(BLUEPIN, b);
  115.         analogWrite(GREENPIN, g);
  116.         delay(FADESPEED);
  117.       }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top