Created
December 2, 2018 01:47
-
-
Save giljr/5b157244637212f85d71395573c83c62 to your computer and use it in GitHub Desktop.
Arduino UNO — Quick Intro A Workshop in BSB with the Kids :) https://medium.com/kidstronics/arduino-uno-quick-intro-94c7c682740a
This file contains hidden or 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
| /* | |
| Kids-Serie#10 | |
| Project : Arduino Start Up | |
| Ino File: _10_ControllingServo_04.ino | |
| */ | |
| #include <Servo.h> | |
| Servo myServo; | |
| void setup() { // put your setup code here, to run once: | |
| myServo.attach(9); | |
| } | |
| void loop() { // put your main code here, to run repeatedly: | |
| int potValue = analogRead(0); // readings from the potentiometer and transform | |
| potValue = map(potValue, 0, 1023, 0, 180); | |
| myServo.write(potValue); // the number so the servo turns 180º | |
| delay(15); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment