Difference between revisions of "Week 6 Lab"

From Robert-Depot
Jump to: navigation, search
(Moving a Servo)
(Moving a Servo)
Line 12: Line 12:
 
  // turning the knob turns the servo
 
  // turning the knob turns the servo
 
  // Robert Twomey - roberttwomey.com
 
  // Robert Twomey - roberttwomey.com
 
 
  #include <Servo.h>  
 
  #include <Servo.h>  
 
 
  Servo myservo;  // create servo object to control a servo  
 
  Servo myservo;  // create servo object to control a servo  
 
                 // a maximum of eight servo objects can be created  
 
                 // a maximum of eight servo objects can be created  

Revision as of 08:30, 5 May 2009

from Electronic Technologies for Art

Controlling the speed AND direction of a motor

L293 quadruple half H-Bridge: http://www.st.com/stonline/books/pdf/docs/1328.pdf

Moving a solenoid

Moving a Servo

// potentiometer_servo
// turning the knob turns the servo
// Robert Twomey - roberttwomey.com
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
               // a maximum of eight servo objects can be created 

int a_in = 0; // analog in pin
int val = 0;  // variable to store analog value
int pos = 0;    // variable to store the servo position 
int delay_time = 15; 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 


void loop() 
{ 
  val=analogRead(a_in); // read value from potentiometer
  pos=map(val, 0, 1023, 0, 180); // map 0-1023 value to 0-180 degrees
  myservo.write(pos); // set servo position
 
  delay(50);
}

Homework

ASSIGNMENT:

Over the course of the next two weeks, we are going to do a mid-term project. Consider it a rehearsal for the final. Your mission: find an object and control it. This could be a toy (see Robosapien example below), a car, a clock (see clock example below), a blender (see blender example below). For this week's homework, you will identify the object you want to control, and write up a preliminary diagram describing how you will control it. A block diagram or flow diagram is a good example: are there inputs coming from sensors, into the microprocessor? If so, put them in the diagram. What are the actuators that are going to produce the output: motors + servos for moving parts, lights for blinking parts (are we bored with this yet), sound, smells. Think expansively! Can you make something bigger than 4x4x4'?

This is going to be a two week project, and a rehearsal for the final. We are going to get our first ideas out of our system with this project, letting you either build on this project or go in a new direction for the final. E-mail me if you are concerned whether or not your idea is feasible. But plan to come to class next week with a written proposal (2 paragraphs), some diagrams, and the thing you want to control.

Next week, in class, we will consider your projects in small groups, and come up with technical implementations (i.e. what circuits/chips/devices do you need) to make your project work. This project will count for part of your final and as homework, approx 25%. Final will remain 35%.


Robosapien example: http://www.arduino.cc/playground/Main/RoboSapienIR

Clock example: http://www.cibomahto.com/2008/03/controlling-a-clock-with-an-arduino/

Blender example: http://www.willitblend.com/