Exercise 6

Electronics Design

Here I designed a board with an Atiny85 with a button, an led, a light sensor, and connections for an RGB led stripe. The files can be found here.For now the board can control the on board led but will later serve as some kind of regulator for the led stripe. The Atiny was programmed using an Arduino Uno and the Arduino IDE. Another board was disigned for the final project. To design the board I used the free software Eagle. In Eagle you have pool of several libraries which can be extended. You start with the schematics by choosing the corresponding electronics from the libraries and place it on the free space in eagle. If you are finished doing so you have some tools helping you to create wires between the components (e.g. connecting a pin from the chosen micro controller to the LED and to the resistor and back to the ground pin). If you are done with that you can swith to the board view. Here you can place the components as they will be on your board. You can ignore the wirering first. When everything is on its place you can use the autorouting tool built in eagle to let the pogram try to place the connections between the chosen components which would be a reallty hard job if you have a more complicated board design. Later on you can still modify the generated solution. Now you can save the files or export it to certain formats is needed.

int photoResistor = 0;
int onThreshold = 400;
int offThreshold = 350;
boolean button = false;

void setup() {
  pinMode(3, OUTPUT); //LED
  pinMode(0,  INPUT);
}

void loop() {
  photoResistor = analogRead(4);
  button = digitalRead(0);

  if(button){
    if (photoResistor > onThreshold){
        analogWrite(3, HIGH);
    }
    else {
      if(photoResistor <= offThreshold) {
          analogWrite(3, LOW);
      }
    }
  }else{
    if (photoResistor > onThreshold){
        analogWrite(3, LOW);
    }
    else {
      if(photoResistor <= offThreshold) {
          analogWrite(3, HIGH);
      }
    }
  }
}