Part7. Encoder sensor control servo
/*
PART7 Encode Sensor CONTROL Servos
Turn the rotary encoder control servos
*/
#include <Servo.h>
int encodeB
=
A0
;
// The A0 pin,read encodeB
int servos
=
6
;
// The 6 pin,driving the servos
Servo servo
;
//Get a servo controller
int angle
=
90
;
//set the servo angle
void setup
()
{
pinMode
(
encodeB
,
INPUT
)
;
// initialize the encodeB pin as an input.
servo
.
attach
(
servos
)
;
attachInterrupt
(
0
,
start
,
FALLING
)
;
//set encodeA interrupt,this board interrupt0 is pin 2
}
void loop
()
{
}
void start
(){
if
(
digitalRead
(
encodeB
)
==
HIGH
){
angle
‐=
30
;
}
else
angle
+=
30
;
if
(
angle
>=
180
)
angle
=
180
;
else
if
(
angle
<=
0
)
angle
=
0
;
servo
.
write
(
angle
)
;
}
Part8. Display Temperature and Humidity
/* Part 8 USE DHT11 Temperature and humidity sensor and Segment
* display Temperature and humidity*/
#include "DHT11.h" //load Temperature and humidity sensor library
#include "TM1637.h"//load Segment display library
Summary of Contents for Arduino Starter Kit
Page 8: ......