help me to design my coding?

Sharing on Tips and Tricks of IoT - hacking, improvement.

help me to design my coding?

Postby Jsheng » Sat Apr 21, 2018 8:53 am

can any people help me to put my this coding (ESP8266_Shield) into a this coding (infrared_sensor).
**without disturbing the process just put inside my coding (ESP8266_Shield) into a this coding (infrared_sensor).
Jsheng
Freshie
 
Posts: 4
Joined: Sat Apr 21, 2018 8:35 am

Re: help me to design my coding?

Postby Jsheng » Sat Apr 21, 2018 9:22 am

THIS IS CODING ESP8266_SHIELD..


#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "88969df388a9489484957a19e84a381c";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ab";
char pass[] = "c1bfa";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(12, 13); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

void setup()
{
// Debug console
Serial.begin(9600);

delay(10);

// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);

Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
Blynk.run();
}
Jsheng
Freshie
 
Posts: 4
Joined: Sat Apr 21, 2018 8:35 am

Re: help me to design my coding?

Postby Jsheng » Sat Apr 21, 2018 9:23 am

THIS IS CODING (INFRARED SENSOR)...

//input
int sen1 = 2;
int sen2 = 3;
int sen3 = 4;
int sen4 = 5;
//output
int lampu1 = 8;
int lampu2 = 9;
int lampu3 = 10;
int lampu4 = 11;
int lampu5 = 12;

int sensorState = LOW;
int val = 0;

void setup()
{
pinMode(sen1, INPUT);
pinMode(sen2, INPUT);
pinMode(sen3, INPUT);
pinMode(sen4, INPUT);
pinMode(lampu1, OUTPUT);
pinMode(lampu2, OUTPUT);
pinMode(lampu3, OUTPUT);
pinMode(lampu4, OUTPUT);
pinMode(lampu5, OUTPUT);

Serial.begin(9600);

}



void loop() {


val = digitalRead(sen1); // read input value
if (val == LOW) { // check if the input is HIGH
digitalWrite(lampu1, LOW);
digitalWrite(lampu2, LOW);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, LOW);
digitalWrite(lampu5, LOW);

if (sensorState == LOW) {
Serial.println("sensor detected!");
sensorState = HIGH;
}

delay(6000);

digitalWrite(lampu1, HIGH);
digitalWrite(lampu2, HIGH);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, HIGH);
digitalWrite(lampu5, HIGH);

if (sensorState == HIGH) {
Serial.println("sensor ended!");
sensorState = LOW;
}
}

if (digitalRead(sen2) == LOW){
digitalWrite(lampu1, LOW);
digitalWrite(lampu2, LOW);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, LOW);
digitalWrite(lampu5, LOW);
delay(6000);
digitalWrite(lampu1, HIGH);
digitalWrite(lampu2, HIGH);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, HIGH);
digitalWrite(lampu5, HIGH);
}

if (digitalRead(sen3) == LOW){
digitalWrite(lampu1, LOW);
digitalWrite(lampu2, LOW);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, LOW);
digitalWrite(lampu5, LOW);
delay(6000);
digitalWrite(lampu1, HIGH);
digitalWrite(lampu2, HIGH);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, HIGH);
digitalWrite(lampu5, HIGH);
}


if (digitalRead(sen4) == LOW){
digitalWrite(lampu1, LOW);
digitalWrite(lampu2, LOW);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, LOW);
digitalWrite(lampu5, LOW);

if (sensorState == LOW) {
Serial.println("sensor detected!");
sensorState = HIGH;
}

delay(6000);
digitalWrite(lampu1, HIGH);
digitalWrite(lampu2, HIGH);
digitalWrite(lampu3, LOW);
digitalWrite(lampu4, HIGH);
digitalWrite(lampu5, HIGH);

if (sensorState == HIGH) {
Serial.println("sensor ended!");
sensorState = LOW;
}
}
}
Jsheng
Freshie
 
Posts: 4
Joined: Sat Apr 21, 2018 8:35 am


Return to Tips and Tricks of IoT

Who is online

Users browsing this forum: No registered users and 2 guests

cron