Thursday, October 1, 2009

Week 4

Circuit building

I began building a simple circuit using:
  • A breadboard
  • A 10K and 150K resistor
  • A switch (part no. MCTH4-47S2-V)
  • An LED
  • The Arduino
  • Some wires
In order to make the job of building the circuit easier, I followed the circuit diagram that I drew which showed the chain of actions and flow of current that would be present in the final circuit. It is advisable to build circuits step by step ie in sequence as opposed to starting at the end, the middle or skipping to and from either.

Pins, when not connected, are in an indeterminate state ie output can be either HIGH or LOW. For this we use a pull-down resistor to hold the output to 0 or LOW when not connected.





Colour code for a 10K resistor:
  • Brown/Black/Orange
Arduino Code:

void setup()
{
pinMode(10, OUTPUT);
pinMode(5, INPUT);
}

void loop()
{
int state = 0;
state = digitalRead(5);
digitalWrite(10, state);
}

No comments:

Post a Comment