This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Blink | |
Turns on an LED on for one second, then off for one second, repeatedly. | |
This example code is in the public domain. | |
*/ | |
// Pin 13 has an LED connected on most Arduino boards. | |
// give it a name: | |
int led = 13; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example 3.1 | |
void setup() | |
{ | |
pinMode (2, OUTPUT); // set pin 2 as an output pin | |
} | |
void loop() | |
{ | |
for (int i = 1; i<=20; i++) // loop 20 times |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void blinkthree() // the name of my function is "blinkthree" | |
{ | |
for (int i = 0; i <3; i++) // loop three times | |
{ | |
digitalWrite(8, HIGH); // turn on LED connected to digital pin 8 | |
delay (1000); | |
digitalWrite(8, LOW); // turn off LED connected to digital pin 8 | |
delay (1000); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void blinkblink(int blinks) // the name of my function is "blinkblink", and receives an integer which is stored in the variable blinks | |
{ | |
for (int i = 0; i <blinks; i++) // loop "blinks" times | |
{ | |
digitalWrite(8, HIGH); // turn on LED connected to digital pin 8 | |
delay (1000); | |
digitalWrite(8, LOW); // turn off LED connected to digital pin 8 | |
delay (1000); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void blinkblink(int blinks, int del) // the name of my function is "blinkblink", and receives an integer which is stored in the variable blinks, and another del ... | |
{ | |
for (int i = 0; i<blinks; i++) // loop "blinks" times | |
{ | |
digitalWrite(8, HIGH); // turn on LED connected to digital pin 8 | |
delay (del); | |
digitalWrite(8, LOW); // turn off LED connected to digital pin 8 | |
delay (del); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float circlearea (float radius) | |
{ | |
float result = 0; | |
result = 3.141592654 * radius * radius; | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Servo myservo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myservo.attach(9); // attaches the servo on pin 9 to the servo object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myservo.write(pos); |
OlderNewer