Init commit with many years of arduino sketches and projects. I dont know if the esp8266 includes much, but there are also libraries. I hope they dont have crazy automatic versioning through the Arduino IDE.

This commit is contained in:
2019-05-30 23:41:53 +02:00
parent 2d047634f2
commit 6c84b31f2c
1480 changed files with 198581 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>
// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>
// Sample : Serial port => Twitter gateway
// Run this program on Arduino and connect via some Serial port terminal software.
// Type a message and hit enter key, and it will be posted to Twitter.
// Arduino IDE Serial Monitor is not usable because it doesn't seem able to send Enter key code.
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };
// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("2307428619-jTdwfFJ4r9aYuaYHQ2YeqBWQNOy6nSg6aTRequb");
char msg[141] = "Test01";
int len = 0;
void setup()
{
delay(1000);
Ethernet.begin(mac, ip);
// or you can use DHCP for autoomatic IP address configuration.
// Ethernet.begin(mac);
Serial.begin(9600);
Serial.print("> ");
}
void loop()
{
if (Serial.available() > 0) {
char recv = msg[len++] = Serial.read();
if (recv == '\b' || recv == 127) { // Backspace
if (len > 1) {
len -= 2;
Serial.print("\b \b");
}
}
else if (recv == '\r' || recv == '\n') { // send CR/LF to post
Serial.print("\r\n");
len--;
msg[len] = 0;
if (len > 0)
post();
len = 0;
Serial.print("\r\n> ");
}
else if (len > 140)
len = 140;
else
Serial.print(recv);
}
}
void post()
{
Serial.println("connecting ...");
if (twitter.post(msg)) {
int status = twitter.wait();
if (status == 200) {
Serial.println("OK.");
} else {
Serial.print("failed : code ");
Serial.println(status);
}
} else {
Serial.println("connection failed.");
}
delay(1000);
}