Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Ryanhu1015 / simple_snake_game_onLED.cpp
Created April 29, 2017 13:58
simple_snake_game_onLED
for (col = 0; col < 8; col++)
{
switch (col % 2)
{
case 0:// "even" col
for (int row = 0 + repeat; row < 8 + repeat; row++)
{
switch (repeat)
{
.....//something doing here
/*skip those varible which i initailized*/
void loop()
{
timeTracing();
}
void transmit(byte addr, byte something)
{
Wire.beginTransmission(addr);
Wire.write(something);
Wire.endTransmission();
unsigned int number[10][8][9] = {/*...is the number i set up in advance*/};
void loop()
{
byte which_number = Wire.read();// the number
switch (which_number)
{
case 0:// number 0
for (byte x = 0; x < 8; x++)
{
for (byte y = 0; y < 8; y++)
@Ryanhu1015
Ryanhu1015 / master_transmit_byte.cpp
Last active May 14, 2017 15:29
master_transmit
void loop()
{
transmit(0x09, 255);
delay(1000);
}
byte received[8][8]; //build an empty array to store the byte received from master
void setup() {
Serial.begin(57600);
Serial.println("test");
Wire.begin(0x09);
Wire.onReceive(receiveEvent);// this function will be triggered whenever something received
}
void loop()
int ledState = LOW;
int buttonState;
int buttonpin = 2;// pin for button
int ledpin = 5;// pin for led
int mapin = 6;// pin for motor
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 200;
@Ryanhu1015
Ryanhu1015 / ESP8266_WiFi_connection.cpp
Created June 5, 2017 16:54
ESP8266 WiFi connection
#include <ESP8266WiFi.h>
const char* ssid = "...";// type in the SSID name which you want to connect
const char* password = "...";// type the password of the WiFi AP you choose
void setup() {
Serial.begin(115200);
delay(10);
// Connect to WiFi network
@Ryanhu1015
Ryanhu1015 / ESP8266_WiFi_server.cpp
Created June 5, 2017 17:13
ESP8266 WiFi server
#include <ESP8266WiFi.h>
const char* ssid = "...";// type in the SSID name which you want to connect
const char* password = "...";// type the password of the WiFi AP you choose
WiFiServer server(80);// ESP8266 server
void setup() {
Serial.begin(115200);
delay(10);
#define pinNUM 5
int location[5] = {2, 3, 4, 5, 6};
unsigned long triggerTime;
unsigned long lastTriggerTime[pinNUM] = {};
void setup()
{
for (int i = 0; i < 5; i++)
{
pinMode(location[i], OUTPUT);
#include <IRremoteESP8266.h>
const int RECV_PIN = 13;
const int R_FD = 2;
const int R_BD = 16;
const int L_FD = 4;
const int L_BD = 5;
IRrecv irrecv(RECV_PIN);