NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <Timer.h>
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

#define firebaseURl "test-9fe68.firebaseio.com"
#define authCode "IPpK4bGUJtDc29gn9UfHj9EYmOJqyxOdbYl5CL1L"

#define wifiName "ES715"
#define wifiPass "AI715nxt4391rcx"
#define wifiName2 "ASUS_jia"//"ES302"
#define wifiPass2 "12347890"//"ES302ES715"

String chipId = "Motor";

Timer TimerSw;

int m5Pin[5][2] = { { 5, 4},
{ 0, 2},
{14,12},
{13,15},
{ 3, 1}}; //爪子
int LedPin = 16;
int SwPin = 10;
int nowMotor[5] = {0,0,0,0,0};

void setup() {
for(int i=0;i<5;i++)
{
for(int j=0;j<2;j++)
{
pinMode(m5Pin[i][j], OUTPUT);
}
}
pinMode(LedPin, OUTPUT);
pinMode(SwPin, INPUT);

//Serial.begin(115200);
setupWifi();
Firebase.begin(firebaseURl, authCode);

TimerSw.every(100, MotorInit);
delay (5000);
}

void loop() {
TimerSw.update();

getData();
delay(100);
}

void MotorTurn(int M_Num,int D)
{
if( (nowMotor[M_Num]-D)>0 ){
analogWrite(m5Pin[M_Num][0], 380);
analogWrite(m5Pin[M_Num][1], 0);
}
else{
analogWrite(m5Pin[M_Num][0], 0);
analogWrite(m5Pin[M_Num][1], 380);
}
delay ( abs(nowMotor[M_Num]-D)*50 );
nowMotor[M_Num] = D;
analogWrite(m5Pin[M_Num][0], 0);
analogWrite(m5Pin[M_Num][1], 0);
}

void MotorInit()
{
if(!digitalRead(SwPin)){
digitalWrite(LedPin, HIGH);
for(int i=0;i<5;i++){
nowMotor[i] = 0;
}
nowMotor[2] = -30;
delay(500);
digitalWrite(LedPin, LOW);
}
}

void getData()
{
String path = chipId;
FirebaseObject object = Firebase.get(path);
String control = object.getString("Control");
int LESsw = object.getInt("LED");

digitalWrite(LedPin, LESsw);

//Serial.print(control);
int M_Num = control.substring(0,1).toInt();
int D = control.substring(1,4).toInt();

//Serial.print(M_Num);
//Serial.println(D);

if(M_Num<5 && M_Num>=0 && D<=100 && D>=-100){
MotorTurn(M_Num, D);
}

}

void setupWifi() {
int x=16;
WiFi.begin(wifiName, wifiPass);
//Serial.println("Hey i 'm connecting...");
while ((WiFi.status() != WL_CONNECTED) && x>0) {
//Serial.print(".");
x--;
delay(500);
}

if(x<=0){
WiFi.begin(wifiName2, wifiPass2);
while ((WiFi.status() != WL_CONNECTED)) {
//Serial.print(".");
delay(500);
}
}

//Serial.println();
//Serial.println("I 'm connected and my IP address: ");
//Serial.println(WiFi.localIP());
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.