1
0
mirror of https://github.com/esp8266/Arduino.git synced 2026-01-06 05:22:30 +03:00

Added Starter Kit examples

This commit is contained in:
Scott
2012-10-12 13:23:48 -04:00
parent 23c2a9618c
commit 9fd14df549
14 changed files with 1171 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/*
Arduino Starter Kit example
Project 9 - Motorized Pinwheel
This sketch is written to accompany Project 9 in the
Arduino Starter Kit
Parts required:
10 kilohm resistor
pushbutton
motor
9V battery
IRF520 MOSFET
1N4007 diode
Created 13 September 2012
by Scott Fitzgerald
http://arduino.cc/starterKit
This example code is part of the public domain
*/
// named constants for the switch and motor pins
const int switchPin = 2; // the number of the switch pin
const int motorPin = 9; // the number of the motor pin
int switchState = 0; // variable for reading the switch's status
void setup() {
// initialize the motor pin as an output:
pinMode(motorPin, OUTPUT);
// initialize the switch pin as an input:
pinMode(switchPin, INPUT);
}
void loop(){
// read the state of the switch value:
switchState = digitalRead(switchPin);
// check if the switch is pressed.
if (switchState == HIGH) {
// turn motor on:
digitalWrite(motorPin, HIGH);
}
else {
// turn motor off:
digitalWrite(motorPin, LOW);
}
}