Handout for Garnet Hertz’ Workshop session
Is on this attached PDF. Hertz Servo Handout
Proposals
LCD Internet code
For this afternoon’s demo, please download this Processing code: LCD-processing.zip
Also, for anyone who’s trying to reconnect this model of LCD display and you’ve (understandably) forgotten the wiring, the datasheet for the device is now conveniently located here. LCD display datasheet
April 6: STEPS
In today’s code, we’re using the arduino’s Stepper Library and arrays to make our stepper motors move according to fixed patterns.
This afternoon’s PRO CHALLENGE:
Store 5 different patterns in arrays. Make the code choose randomly which patterns to follow.
For this afternoon’s code, click “Read More”
March 30th
Tom Igoe’s Website: www.tigoe.net
The raw code for controlling a stepper can be found here on the website.
March 23: Code-a-palooza
Two different sketches today. Click “read more” to see them, starting with the random movement sketch, and then continuing with our limit switch demo.
March 16th: In Review
Hi All! We made not one, not two, but THREE codes today in class. All of these codes involve controlling a motor via a TIP122 transistor.
For the afternoon, get cracking on mid-term projects.
March 9th in Review
As usual, our code from the morning is posted beneath the break.
From here, we’re taking on Project 12 under the “Projects” heading of this site:
Using a colored RGB LED, connect each of the pins of the LED to three pins on the Arudino that supports PWM. Now, construct a color mixer that varies the levels of Red, Green and Blue the LED displays using three potentiometers connected to pins 0, 1, and 2 of the board. This essentially uses the ideas brought forward in Project 8, but applying them to three pins of a colored LED rather than a single pin.
Also note that there were two concepts we covered this morning that are not presented here in the code. These were two different ways of creating conditional loops:
Have fun!
March 2: This Week in Review
After the jump, you’ll find the code we wrote in class this morning. The circuit that accompanies this code has two LEDs (with your standard 220-ohm resister in series) attached to pin 9 and pin 13. Additionally, we have a 10K potentiometer with the two outer leads going to +5VDC and GND respectively, and the middle lead going to analog in 0.
Note that there are three new concepts here:
- Creating our own functions. Here, we create a “void” function called “blink.” This is a way of keeping a set of actions in one handy section of code, called a function. We can tell the program to jump to that function any time, and it saves us having to write the code out every single time we want to use it. Furthermore, we can pass along certain pieces of information, like values or variables, to use. We do this by including that information in the brackets when we call the function, and defining what we’ll use it for in the declaration of the function itself. More advanced info on functions at the Arduino Reference.
- analogRead. This is a function that only works with the “analog in” pins running along one side of the Arduino board. It reads the voltage coming into that pin, and then gives us a number between 0 and 1023, where 1023 would be 5VDC, 512 would be 2.5 VDC, and 0 would be 0 VDC. This process is called Analog-to-Digital-Conversion (ADC).
- analogWrite. This writes a PWM value to your pin. PWM isn’t true analog, it’s faking it. What it really does is turn the pin on and off so fast that we can perceive it as outputing a lower voltage. We can control the “duty cycle” (i.e. what percentage of the time it’s flipped on vs. what percentage of the time it’s off to give a range of output values. It’s sort of the equivalent of flashing a white card and a black card at you back and forth really fast to trick you into think you’re seeing gray. This function only works on the Arduino pins marked with a ~ sign (Uno borads) or the letters PWM (on earlier Arduino boards).
For the afternoon, we’re going to try to make the changes to our code and circuit as outlined on this page: Project 9. Post your results in the comments section of that page!
February 23: This Week in Review
After the jump, you’ll find a transcription of the program we “live-coded” in class today. It’s one solution to the problem we posed last week: Create a blinking light Arduino program that uses a switch to turn it on and off, and then use two other switches to make the light blink faster or slower.
THIS WEEK’S ALL-STAR CHALLENGES
If you’ve worked through this code and feel like you understand it, try to add these wrinkles to your code:
1) Add limits to the blinking rate, so there’s a maximum and minimum speed (bonus: this will also save your Arduino from crashing when it gets to negative values for delay times)
2) Change the method of speeding up or slowing down the blinking to be more proportional. (i.e.
3) PRO CHALLENGE: Set it up so that the blinking light is, by default, cyclically speeding up and then slowing down when you turn it on. Then use the two additional buttons to change the rate of speeding up and slowing down.
