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 <Adafruit_NeoPixel.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket | |
#endif | |
#define BUTTON_PIN 6 // Digital Input from Breadboard | |
#define BOARD_PIN 5 // Digital Input from Breakout Board | |
#define PIXEL_PIN 2 // Digital Output connected to the NeoPixels. |
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
/* | |
DigitalReadSerial | |
Reads a digital input on pin 2, prints the result to the Serial Monitor | |
http://www.arduino.cc/en/Tutorial/DigitalReadSerial | |
*/ | |
// digital pin 2 has a pushbutton attached to it. Give it a name: | |
int pushButton = 2; |
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
/* | |
Analog input, analog output, serial output | |
Reads an analog input pin, maps the result to a range from 0 to 255 and uses | |
the result to set the pulse width modulation (PWM) of an output pin. | |
Also prints the results to the Serial Monitor. | |
The circuit: | |
- potentiometer connected to analog pin 0. | |
Center pin of the potentiometer goes to the analog pin. |
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
/* | |
Analog input, analog output, serial output | |
Reads an analog input pin, maps the result to a range from 0 to 255 and uses | |
the result to set the pulse width modulation (PWM) of an output pin. | |
Also prints the results to the Serial Monitor. | |
The circuit: | |
- potentiometer connected to analog pin 0. | |
Center pin of the potentiometer goes to the analog pin. |
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 <Adafruit_NeoPixel.h> | |
#include <Servo.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket | |
#endif | |
int analogInPin1 = A0; // Analog input pin that the potentiometer is attached to | |
int analogInPin2 = A1; // Analog input pin that the photoreceptor is attached to | |
int servoPin1 = 5; // Analog output pin |
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
// These constants won't change. They're used to give names to the pins used: | |
int analogInPin1 = A0; // Analog input pin that the first potentiometer is attached to | |
int analogInPin2 = A1; // Analog input pin that the second potentiometer is attached to | |
int sensorValue1 = 0; // value read from the first potentiometer | |
int sensorValue2 = 0; // calue read from the second potentiometer | |
void setup() { | |
// initialize serial communications at 9600 bps: | |
Serial.begin(9600); |
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
int LEDpin = 4; | |
int incomingByte; | |
void setup() { | |
pinMode(LEDpin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
if (Serial.available() > 0) { |
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
// These constants won't change. They're used to give names to the pins used: | |
int xAxis = A0; // Analog input pin that the x-axis of the joystick is attached to | |
int yAxis = A1; // Analog input pin that the y-axis of the joystick is attached to | |
int sensorValue1 = 0; // value read from the potentometer | |
int sensorValue2 = 0; // calue read from the photoreceptor | |
int LEDpin1 = 4; | |
int LEDpin2 = 7; | |
int LEDpin3 = 8; |
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
const int switchPin = 2; // switch input | |
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A) | |
const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A) | |
const int enablePin = 9; // H-bridge enable pin | |
void setup() { | |
// set the switch as an input: | |
pinMode(switchPin, INPUT); | |
// set all the other pins you're using as outputs: |
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 <Stepper.h> | |
const int stepsPerRevolution = 64; // change this to fit the number of steps per revolution | |
// initialize the stepper library on pins 8 through 11: | |
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); | |
void setup() { | |
// set the speed at 60 rpm: | |
myStepper.setSpeed(60); |
OlderNewer