August 18th 2017
Arduino 5v output and ground
DC motor is always on
What happens when you switch the positive and negative wires?
Arduino digital ~9 (can emulate analog write) and ground
This time we are going to use a breadboard, although this circuit is so simple, you could get away with skipping it
int motor = 9;
int speed = 0;
int fadeAmount = 5;
void setup() {
pinMode(motor, OUTPUT);
}
void loop() {
analogWrite(motor, speed);
speed = speed + fadeAmount;
if (speed <= 0 || speed >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
Arduino A0 and D~9, 5V, and ground, and a potentiometer knob
#include <Servo.h> Servo myservo; int potpin = 0; int val; void setup() { myservo.attach(9); } void loop() { val = analogRead(potpin); val = map(val, 0, 1023, 0, 180); myservo.write(val); delay(15); }
Also need a "Big Easy Driver"
(no stepper motor or Big Easy Driver in Tinkercad ðŸ˜)
int dirPin = 8; int stepPin = 9; void setup() { pinMode(8, OUTPUT); pinMode(9, OUTPUT); digitalWrite(8, LOW); digitalWrite(9, LOW); Serial.begin(9600); } void loop() { // Basic digitalWrite(9, HIGH); delay(1); digitalWrite(9, LOW); delay(1); }
// add `stepCount = 0;` to setup code block //STEP AND COUNT //step in one direction counting down from 0 to 1200. // Â for (int stepCount = 0 ; stepCount <= 1200; stepCount += 1) { // Â digitalWrite(8, LOW); // Â digitalWrite(9, HIGH); // Â delay(1); Â Â Â Â Â // Â digitalWrite(9, LOW); // Â delay(1); // Â } //
// add `stepCount = 0;` to setup code block //STEP AND COUNT
// step in opposite direction counting down from 1200 to 0. // Â for (int stepCount = 1200 ; stepCount >= 0; stepCount -= 1) { // Â digitalWrite(8, HIGH); // Â digitalWrite(9, HIGH); // Â delay(1); Â Â Â Â Â // Â digitalWrite(9, LOW); // Â delay(1); // Â }
We chose one of the following machines: