Recent Changes - Search:

Main
Intro to PComp Home
Weekly Topics & Assignments
Wednesday Class Dates

Links:

Final Projects


Midterm Projects

PmWiki

edit SideBar

GroupResources

List of our expenses




guys the Arduino code you used for the magnetic sensor was left on the laptop in the Phys Comp area. in case you did not save it, i am posting it here -marc

// declare variables: int switchPin = 2; // digital input pin for a switch int yellowLedPin = 3; // digital output pin for an LED //int redLedPin = 4; // digital output pin for an LED int switchState = 0; // the state of the switch

void setup() {

  pinMode(switchPin, INPUT);       // set the switch pin to be an input
  pinMode(yellowLedPin, OUTPUT);   // set the yellow LED pin to be an output
 // pinMode(redLedPin, OUTPUT);      // set the red LED pin to be an output

}

void loop() {

  // read the switch input:
  switchState = digitalRead(switchPin);

  if (switchState == 1) {
    // if the switch is closed:
    digitalWrite(yellowLedPin, HIGH);    // turn on the yellow LED
    //digitalWrite(redLedPin, LOW);       // turn off the red LED
  } 
  else {
    // if the switch is open:
    digitalWrite(yellowLedPin, LOW);   // turn off the yellow LED
    //digitalWrite(redLedPin, HIGH);     // turn on the red LED
  }

}

Edit - History - Print - Recent Changes - Search
Page last modified on October 22, 2006, at 11:45 AM