Set up


  • Mac Download the driver Or Windows download this driver
  • Double click the ZIP file do unzip it
  • Open the folder ~/Downloads/CH341SER_MAC
  • Run installer found in that folder
  • If asked to restart, do not restart just yet.
  • This next step is only needed if you are on OS-X Yosemite. For older versions of OS-X you do not need it:
    • Open Terminal Application (it's located in /Application/Utilities) and type this command once you see a prompt:
    • sudo nvram boot-args="kext-dev-mode=1"
    • See this post if you wish to know why we need to run this command. I believe you need to do this because the driver is not signed properly, or is simply too old for Yosemite. Hopefully newer versions won't require this step and will automatically become enabled.
  • Now restart your laptop

ARDUINO

Blinking LED

external image Screen%20Shot%202015-05-18%20at%2014.39.55.png


Arduino Buttons

arduino_button1.png
arduino_button2.png

Buttons Continued...

button3.png

Try adding 3 buttons (one for each light). You will need to modify the code (the code on Edmodo and for the image above is for 2 buttons and LED's


Steepper Motor with buttons

This lesson we are looking at stepper motors, Stepper motors are accurate motors with internal cogs that can be precicely controlled.

Your task is to program the stepper motor using a button.

1, Get the motor working using the code below. You will not be getting a diagram.


Scroll Down to see all the code

/*
Stepper Motor Control - button

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The button is using pin 2

The motor should revolve one revolution in one direction IF the button is pressed

Created 15 May 2015

by Jon Clark

*/

#include <Stepper.h>

int buttonPin = 2;

const int stepsPerRevolution = 2037; this is the number of steps our stepper motors take per revolution

initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 11, 9);

void setup() {

pinMode(buttonPin, INPUT); this time we will set the pin as INPUT

set the speed at 14 rpm (max for our motors):
myStepper.setSpeed(14);
initialize the serial port (so se can see using serial monitor whats happening:
Serial.begin(9600);
}

void loop() {
if (digitalRead(buttonPin)==HIGH) IF THIS HAPPENS
{
Serial.println("pressed");
step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution*1); moving in a clockwise direction (1 revolutions)
delay(500);
}
else{ // this will happen if the button is not pressed
Serial.println("not pressed");

}
}


2. You need to use the code above. You will not be getting a diagram.
You need to modify the code above using previous weeks code.

This should include an if within an if (like lesson 4)
The Challenge this week is to:


  • Have 2 buttons...
  • one to turn the motor 1 revolution clockwise
  • one to turn the motor 1 revolution counterclockwise


Extension. Change the code to alter what the motor can do.