7. Electronics design

This week I worked on redraw the echo hello-world board, add a button and a LED, both with current-limiting resistor. I checked the design rules, made it, and tested it…

Code Example

Blinking a LED:

// constants won't change. They're used here to set pin numbers:
const int greenPin = 7;     // the number of the green LED pin

int greenState = LOW;       

void setup() {
  // put your setup code here, to run once:
    pinMode(greenPin, OUTPUT);
}

//turns the LED off
void bothOff(){
  greenState = LOW;


  digitalWrite(greenPin, greenState);

}

//turns LED on
void bothOn(){
  greenState = HIGH;


  digitalWrite(greenPin, greenState);

}

void loop() {
  // put your main code here, to run repeatedly:
  bothOff();
  delay(250);
  bothOn();
  delay(250);
}

Turning off the LED whenever we press a button:

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 3;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Here we see the schematic of the echo hello-world board, after adding a button and a green LED, both with current-limiting resistors of 490Ω:

And here we see the final board as produced by AutoCAD Eagle:

The board file produced by Eagle was edited using Gimp to produce the Complete layout of the board to be milled:

Final Layout (ready for milling):

Final Outline (ready for milling):

Milling the card on the Monofab mill using MODS:

And this is the final result, after soldering the components:

From Youtube

The echo hello-world board blinking its LED:

The echo hello-world board lightning its LED whenever the button is pressed: