analog sensor
#include
int pinNr=0;
//int incr=5;
void setup() {
Serial.begin(9600);
pinMode(3, OUTPUT);
}
void loop() {
int pinValue=analogRead(pinNr);
analogWrite(3,pinValue/4);
Serial.println(pinValue);
//delay(1000);
}
Servo Motor
#include
int incr=3;
int dir=0;
int counter=0;
Servo servoMotor;
int analogValue=0;
int servoPin=2;
void setup(){
servoMotor.attach(servoPin);
}
void loop(){
if (dir==1){
counter+=incr;
}
else{
counter-=incr;
}
if(counter>=255){
dir=0;
}
if(counter<=0){
dir=1;
}
analogValue=counter;
analogValue= map(analogValue, 0, 255, 0, 179);
servoMotor.write(analogValue);
delay(1000);
}
Arduino book pdf
download the open source arduino book here
continuous motor
int counter=0;
int dir=1;
int incr=5;
// servo
//
void setup(){
pinMode(11,OUTPUT);
digitalWrite(11,HIGH);
}
void loop(){
if(dir==1){
counter+=incr;
}
else{
counter-=incr;
}
if(counter>=255){
dir=0;
}
if(counter<=0){
dir=1;
}
analogWrite(11,counter);
delay(15);
}
Code of day #1
//
// everthing you read in GREY is a comment
// the computer ignores it completely
//
//
//
// initialize some stuff.
// define a few variables
// of different types
int age=0;
int pastDays=0;
long myTime=0;
int hourOfDay=0;
//
//
//
// setup and loop MUST be there
void setup(){
}
void loop(){
breath();// will execute everything inside the breath() function
if(pastDays>365){// evaluating how many days have past since last birthday
haveABirthday(); // execute whatever is in the haveABirthday() function
}
pastDays=pastDays+1;// add one to the pastDays variable (increase it)
if(hourOfDay==8){// check if the hour of day is...
eat();// execute whatever is in the eat() function
}
if(hourOfDay==13){// check if the hour of day is...
eat();// execute whatever is in the eat() function
}
if(hourOfDay==19){// check if the hour of day is...
eat();// execute whatever is in the eat() function
}
}
//
//
//
// breath is a function()
void breath(){
myTime=millis();
}
// eat is a function()
void eat(){
// make sure very few
//things happen before you eat
}
// haveABirthday is a function()
void haveABirthday(){
age=age+1;
pastDays=0;
}
// tellMyAge is a function()
int tellMyAge(){
return age;
}
Marcel Duchamp, Rotating discs and optical illusions
Anémic Cinéma, 1926
Rotoreliefs, 1935
Optical Illusion Machine, 1925
Rotary Demisphere, 1925















































