Lesson Guide
Lesson 1: EEPROM Storage Program
This lesson demonstrates how to use the EEPROM storage capabilities with an Arduino.
- Click Sketch in the Arduino IDE, select Manage Library in Include Library, search for
AT24C256_library, and click Install. - Click File in the Arduino IDE, and select
read_wirtefrom theAT24C256_libraryexamples. - Click Upload, and then click Serial Monitor in the upper right corner of the IDE.
Screenshot of the Arduino Library Manager dialog box. It displays fields for Type, Topic, and a search bar. The library named 'AT24C256_library' is shown, with an 'Install' button available.
Lesson 2: 0.96in LED Screen Program
This lesson covers programming a 0.96-inch LED screen using Arduino.
- Click Sketch in the Arduino IDE, select Manage Library in Include Library, search for
U8glib, selectU8glib, and click Install. - Click File in the Arduino IDE and select
FPSfrom theU8glibexamples. - Locate the line
// U8GLIB_SSD1306_128X64 u8g (U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // I2C/TWI code. Delete the//to uncomment this line, then click Upload in the upper left corner.
Screenshot of the Arduino Library Manager dialog box. It displays fields for Type, Topic, and a search bar. The library named 'U8glib' is shown, with an 'Install' button available.
Lesson 3: MPU6050 Six Axis Gyroscope Program
This lesson focuses on using the MPU6050 Six Axis Gyroscope with Arduino.
- Click Sketch in the Arduino IDE, select Manage Library in Include Library, search for
Adafruit_MPU6050, and click Install. - Click File in the Arduino IDE and select
basic_readingsfrom theAdafruit_MPU6050examples. - Click Upload, then click Serial Monitor in the upper right corner of the IDE, and switch the baud rate from 9600 to 115200.
Note on Calibration: Because the initial values of all axes of the MPU-6050 cannot be consistent, when Acceleration's X and Y axes are not equal to 0 m/s^2 and the Z axis is not equal to 9.8 m/s^2, and the X, Y, and Z values for Rotation are not equal to 0 rad/s, you can adjust the error values through the program to make the initial output relatively correct.
Screenshot of the Arduino Library Manager dialog box. It displays fields for Type, Topic, and a search bar. The library named 'Adafruit MPU6050' is shown, with an 'Install' button available.
Lesson 4: Passive Buzzer Program
This lesson provides code for a passive buzzer using Arduino.
#define Pot A3
#define Buzzer 8
int PotBuffer = 0;
void setup()
{
pinMode(Buzzer,OUTPUT); // The buzzer pin is set to output
}
void loop()
{
PotBuffer = analogRead(Pot); // Reading the AD value
for(int i = 0 ; i < 50 ; i++) // Cycle 50 times
{
digitalWrite(Buzzer,HIGH); // Set the output high level
delayMicroseconds(PotBuffer); // The delay PotBuffer value is us
digitalWrite(Buzzer,LOW); // Set the output low level
delayMicroseconds(100); // Delay 100us
}
delay(1000); // Delay 1000ms
}
Lesson 5: DH11 Temperature and Humidity Sensor Program
This lesson demonstrates reading temperature and humidity using the DH11 sensor with Arduino.
- Click Sketch in the Arduino IDE, select Manage Library in Include Library, search for
DHT11, selectDFRobot_DHT11, and click Install. - Click File in the Arduino IDE, and select
readDHT11from theDFRobot_DHT11examples. - Change
#define DHT11_PIN 10to#define DHT11_PIN3and click Upload on the IDE home page. - Click Serial Monitor in the upper right corner of the IDE and switch the baud rate from 9600 to 115200. Wait approximately 1 second to get the current temperature and humidity readings.
Screenshot of the Arduino Library Manager dialog box. It displays fields for Type, Topic, and a search bar. The library named 'DFRobot_DHT11' is shown, with an 'Install' button available. Another image shows the Arduino IDE code editor with an arrow pointing to line 15, which reads '#define DHT11_PIN 3'.
Lesson 6: Infrared Remote Reception Program
This lesson covers receiving infrared signals using Arduino.
- Click Sketch in the Arduino IDE, select Manage Library in Include Library, search for
IRremote, and click Install. - Click File in the Arduino IDE and select
ReceiveDemofrom theIRremoteexamples. - Click Upload, then click Serial Monitor in the upper right corner of the IDE, and switch the baud rate from 9600 to 115200. Use a matching remote control to align with the infrared receiving module and press any key. When corresponding data appears, the module will function normally.
Screenshot of the Arduino Library Manager dialog box. It displays fields for Type, Topic, and a search bar. The library named 'IRremote' is shown, with an 'Install' button available. Another image shows the Serial Monitor output displaying infrared data, including protocol information.
Lesson 7: Photoresistor Program
This lesson provides code for using a photoresistor (light sensor) with Arduino.
#define ADpin A3
#define LED 13
int ADBuffer = 0;
void setup()
{
pinMode(LED,OUTPUT);
Serial.begin(9600); // The baud rate is 9600
}
void loop()
{
ADBuffer = analogRead(ADpin); // Reading the AD value
Serial.print("AD = ");
Serial.println(ADBuffer);
if(ADBuffer > 800) // If the ADBuffer value is larger than the set value, the illumination intensity is smaller than the set value
{
digitalWrite(LED,HIGH); // Light up LED
}
else
{
digitalWrite(LED,LOW); // Turn off LED
}
delay(500); // Delay 500ms
}
Lesson 8: Button Program
This lesson provides code for reading button inputs with Arduino.
#define KEY0 digitalRead(4)
#define KEY1 digitalRead(5)
#define KEY0_PRES 1
#define KEY1_PRES 2
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
int key;
key=KEY_Scan(0);// Scan key
if (key==1)
{ digitalWrite(LED_BUILTIN, HIGH); }
if (key==2)
{ digitalWrite(LED_BUILTIN, LOW); }
}
u8 KEY_Scan(u8 mode)
{
pinMode(4,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
static u8 key_up=1;// Press the button to release the sign
if(mode)key_up=1; // Support link
if(key_up&&(KEY0==0||KEY1==0))
{
delay(10);// Jitter elimination
key_up=0;
if(KEY0==0)return KEY0_PRES;
else if(KEY1==0)return KEY1_PRES;
}else if(KEY0==1&&KEY1==1)key_up=1;
return 0;// No key to press
}