Commit 70c15c22 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+246 KiB

File added.

No diff preview for this file type.

+59.3 KiB

File added.

No diff preview for this file type.

+16 −0
Changes for ArduinoCookbook/ch01/ch1r5/ch1r5.pde: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
const int ledPin =  13;    // LED connected to digital pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(2000);                  // wait for two seconds
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(2000);                  // wait for two seconds
}
      
    
+18 −0
Changes for ArduinoCookbook/ch01/ch1r6/ch1r6.pde: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
const int ledPin =  13;     // LED connected to digital pin 13
const int sensorPin = 0;    // connect sensor to analog input 0

void setup()
{
  pinMode(ledPin, OUTPUT);  // enable output on the led pin
}

void loop()
{
  int rate = analogRead(sensorPin);    // read the analog input
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(rate);                  // wait duration dependent on light level
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(rate);
}
      
    
+25 −0
Changes for ArduinoCookbook/ch01/ch1r6A/ch1r6A.pde: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
const int ledPin = 13; // LED connected to digital pin 13
const int sensorPin = 0; // connect sensor to analog input 0

// the next two lines set the min and max delay between blinks
const int minDuration = 100; // minimum wait between blinks
const int maxDuration = 1000; // maximum wait between blinks

void setup()
{
  pinMode(ledPin, OUTPUT); // enable output on the led pin
  Serial.begin(9600); // initialize Serial
}

void loop()
{
  int rate = analogRead(sensorPin); // read the analog input
  // the next line scales the blink rate between the min and max values
  rate = map(rate, 200,800,minDuration, maxDuration); // convert to blink rate
  Serial.println(rate); // print rate to serial monitor
  digitalWrite(ledPin, HIGH); // set the LED on
  delay(rate); // wait duration dependent on light level
  digitalWrite(ledPin, LOW); // set the LED off
  delay(rate);
}
    
Loading