This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bit patterns in order with segments a, b, c, d, e, f, g where g is LSB and MSB is just unused. | |
| byte digits[] = {0b01111110 , 0b00110000, 0b01101101, 0b1111001, 0b00110011, 0b01011011, 0b01011111, 0b01110000, 0b01111111, 0b01111011}; | |
| // Let's assume that the segments are on pins 3 through 9, so it's the top 5 bits of PORTD and the bottom 2 bits of PORTB | |
| // They're in order so segment a is connected to pin 9 and segment g is connected to pin 3. | |
| void displayNumber(byte aNumber) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code compiles but is untested | |
| // In reality it would be too slow | |
| // But it is easier to understand the | |
| // concept here with digitalRead than | |
| // it is with diret port reads | |
| // I have used the same code written | |
| // with port reads many times to read | |
| // encoders. It works. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Encoders connected to PORTC | |
| // The First encoder is on pins 0 and 2 | |
| // Second encoder is on pins 1 and 3 | |
| // So the A pins are together on 0 and 1 | |
| // B pins on 2 and 3 | |
| int printInterval = 500; | |
| volatile int encoderCount[2] = {0, 0}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WiFiServer server(1234); | |
| WiFiClient client; | |
| void setupWiFi() { | |
| Serial.println("Setting Up WiFi"); | |
| WiFi.mode(WIFI_STA); | |
| IPAddress ipa(192, 168, 1, 75); | |
| // IPAddress dns(192, 168, 1, 1); | |
| IPAddress gate(192, 168, 1, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "SerialServo.h" | |
| int pos = 0; | |
| int servo = 0; | |
| boolean reading = false; | |
| boolean gotServo = false; | |
| Servo servos[6]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Do not remove the include below | |
| #include "espwifi.h" | |
| #define dirA D3 | |
| #define dirB D4 | |
| #define enA D1 | |
| #define enB D2 | |
| WiFiServer server(1234); | |
| WiFiClient client; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.Event; | |
| import java.awt.GridLayout; | |
| import java.awt.event.ActionEvent; | |
| import java.awt.event.ActionListener; | |
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.io.PrintWriter; | |
| import java.net.Socket; | |
| import java.net.UnknownHostException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| byte digits[] = {0b1111110 , 0b0110000, 0b1101101, 0b1111001, 0b0110011, 0b1011011, 0b1011111, 0b1110000, 0b1111111, 0b1111011}; | |
| // pins to segments g,f,e,d,c,b,a | |
| byte pins[] = {3,4,5,6,7,8,9}; | |
| void displayNumber(int aNumber) { | |
| for (int i = 0; i < 7; i++) { | |
| digitalWrite(pins[i], digits[aNumber] & (1 << i)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int buttonState = HIGH; | |
| boolean buttonPressed = false; | |
| void pollButton() { | |
| static int lastState = HIGH; | |
| static unsigned long pressTime = 0; | |
| int curState = digitalRead(BUTTON_PIN); | |
| if (curState != lastState) { | |
| pressTime = millis(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define SEC_PER_MIN (60) | |
| #define SEC_PER_HOUR (60ul * 60) | |
| #define SEC_PER_DAY (24ul * 60 * 60) | |
| unsigned long countdownTime = 0; | |
| void setup(){ |