This file contains 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
long record = 0; | |
byte rightEchoState; | |
byte lastRightState = LOW; | |
float awayFromRight; | |
void loop(){ | |
record++; | |
rightStateChange(); | |
} |
This file contains 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
void steppingMotor() | |
{ | |
digitalWrite(X_STP, HIGH); | |
digitalWrite(Y_STP, HIGH); | |
delayMicroseconds(1); | |
digitalWrite(X_STP, LOW); | |
digitalWrite(Y_STP, LOW); | |
} |
This file contains 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 EN 8 // state LOW works | |
#define X_DIR 5 | |
#define Y_DIR 6 | |
#define X_STP 2 | |
#define Y_STP 3 | |
void setup() { | |
Serial.begin(115200); | |
pinMode(X_DIR, OUTPUT); //the initail pin mode of stepping motor | |
pinMode(X_STP, OUTPUT); |
This file contains 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
//there are three option | |
char *ntpServerName = "tick.stdtime.gov.tw"; | |
char *ntpServerName2 = "clock.stdtime.gov.tw"; | |
char *ntpServerName3 = "time.stdtime.gov.tw"; | |
void setup() | |
{ | |
//.skip this part | |
//. | |
//. |
This file contains 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
extern "C" | |
{ | |
#include "user_interface.h" | |
} | |
os_timer_t myTimer; | |
void user_init(void) // the function will be set in setup to trigger the ISR function | |
{ | |
os_timer_setfn(&myTimer, timerCallback, NULL); |
This file contains 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
IPAddress timeServerIP; // time.nist.gov NTP server address | |
const char *ntpServerName = "tick.stdtime.gov.tw";// this is one of the NTP server | |
const int NTP_PACKET_SIZE = 48; | |
byte packetBuffer[NTP_PACKET_SIZE]; | |
WiFiUDP udp; | |
unsigned long sendNTPpacket(IPAddress &address) | |
{ |
This file contains 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
unsigned long timeNow = 0; | |
unsigned long timeLast = 0; | |
int seconds = 0; | |
int minutes = 0; | |
int hours = 0; | |
int days = 0; | |
timeNow = millis()/1000;// millis is the function i have mentioned above | |
seconds = timeNow - timeLast; |
This file contains 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 received[8][8]; | |
void setup() | |
{ | |
//skip this part | |
} | |
void loop() | |
{ | |
for (byte x = 0; x < 8; x++) | |
{ | |
for (byte y = 0; y < 8; y++) |
This file contains 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 <Wire.h> | |
#include <Colorduino.h> | |
byte number6[4][8] = {{0,0,0,0,0,0,0,0},{1,0,0,1,1,1,1,0},{1,0,0,1,0,0,1,0},{1,1,1,1,1,1,1,0}}; | |
void setup() | |
{ | |
//skip this part | |
} | |
void loop() | |
{ |
This file contains 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
void sonar() | |
{ | |
float duration, distance; | |
digitalWrite(trig, HIGH); | |
delayMicroseconds(100); | |
digitalWrite(trig, LOW);//change trig pinmode to spark the signal | |
duration = pulseIn (echo, HIGH);// the duration of state of echo remaining HIGH | |
distance = duration/58;// 58 is from (duration/2)/29 |