Controler PDF
Controler PDF
Controler PDF
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
void setup() {
Serial.begin(9600);
void loop() {
Serial.println(sensorValue);
}
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the Serial Monitor
http://www.arduino.cc/en/Tutorial/DigitalReadSerial
*/
int pushButton = 2;
void setup() {
Serial.begin(9600);
pinMode(pushButton, INPUT);
void loop() {
Serial.println(buttonState);
}
/*
Fade
This example shows how to fade an LED on pin 9 using the analogWrite()
function.
The analogWrite() function uses PWM, so if you want to change the pin you're
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
http://www.arduino.cc/en/Tutorial/Fade
*/
void setup() {
pinMode(led, OUTPUT);
void loop() {
analogWrite(led, brightness);
fadeAmount = -fadeAmount;
delay(30);}
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
*/
void setup() {
Serial.begin(9600);
void loop() {
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
Serial.println(voltage);
}
/* Sweep
by BARRAGAN <http://barraganstudio.com>
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
void setup() {
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
}
/*
Parts required:
- three photoresistors
by Scott Fitzgerald
http://www.arduino.cc/starterKit
*/
const int redSensorPin = A0; // pin with the photoresistor with the red gel
const int greenSensorPin = A1; // pin with the photoresistor with the green gel
const int blueSensorPin = A2; // pin with the photoresistor with the blue gel
int redValue = 0; // value to write to the red LED
int redSensorValue = 0; // variable to hold the value from the red sensor
int greenSensorValue = 0; // variable to hold the value from the green sensor
int blueSensorValue = 0; // variable to hold the value from the blue sensor
void setup() {
Serial.begin(9600);
pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
void loop() {
redSensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);
Serial.print(redSensorValue);
Serial.print(greenSensorValue);
Serial.println(blueSensorValue);
/*
In order to use the values from the sensor for the LED, you need to do some
math. The ADC provides a 10-bit number, but analogWrite() uses 8 bits.
of the output.
*/
redValue = redSensorValue / 4;
greenValue = greenSensorValue / 4;
blueValue = blueSensorValue / 4;
Serial.print(redValue);
Serial.print(greenValue);
Serial.println(blueValue);
/*
Now that you have a usable value, it's time to PWM the LED.
*/
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}
/*
Parts required:
- 10 kilohm resistor
- pushbutton
- motor
- 9V battery
- IRF520 MOSFET
- 1N4007 diode
by Scott Fitzgerald
http://www.arduino.cc/starterKit
*/
pinMode(motorPin, OUTPUT);
pinMode(switchPin, INPUT);
void loop() {
switchState = digitalRead(switchPin);
if (switchState == HIGH) {
digitalWrite(motorPin, HIGH);
} else {
digitalWrite(motorPin, LOW);
}
/*
Parts required:
- servo motor
- 10 kilohm potentiometer
by Scott Fitzgerald
http://www.arduino.cc/starterKit
*/
#include <Servo.h>
int const potPin = A0; // analog pin used to connect the potentiometer
int potVal; // variable to read the value from the analog pin
int angle; // variable to hold the angle for the servo motor
void setup() {
void loop() {
Serial.print("potVal: ");
Serial.print(potVal);
Serial.println(angle);
myServo.write(angle);
delay(15);
}
/* Motor Board IR Array Test
the robot.
*/
#include <ArduinoRobotMotorBoard.h>
void setup() {
Serial.begin(9600);
RobotMotor.begin();
void loop() {
bar = bar + RobotMotor.IRread(1) + ' ' + RobotMotor.IRread(2) + ' ' + RobotMotor.IRread(3) + ' ' +
RobotMotor.IRread(4) + ' ' + RobotMotor.IRread(5);
Serial.println(bar);
delay(100);
}
/* Motor Core
*/
#include <ArduinoRobotMotorBoard.h>
void setup() {
RobotMotor.begin();
void loop() {
RobotMotor.parseCommand();
RobotMotor.process();