Input Devices

The goal of this week is to make a board with a sensor and get that sensor to read out.

Board Design

The design of the board is done with EAGLE.
I chose to use the TINY-45 because it is easier to work with the 8 pin chip and I only need 1 or 2 I/O pins for this project.

It is getting easier to arrange elements, but I still find it helpful to look at some of the simple boards from the Fab Academy notes.

This is the schematic.Placed each of the elements(ISP,Tiny45,R,C,FTDI connection).
Wired elements.

The process for designing the layout. Positioned elements. Autorouted the board. Adjusted the cicuit elements. Autorouted the board. Repeated a couple of times until the board was clean and could be milled on one layer.

Milling the Board

I used Easel software which requires an SVG image. I generated the PNG from Eagle. (Use only 1 layer and Monochrome during export.) I then used an online PNG to SVG converter and cleaned up the board by redrawing some lines using Inkscape.


Soldering when quick because there are so few components. I placed a little solder on each of the pads. Held the component to the pad and reheated the solder.


First programmed using the Hello Button boatd This let me know that the board work.
I realized I made one generic input slot to which I soldered a switch. However, there is no immediate outcome.
I programmed the Hello-Echo + Button board so that a button when pressed would immediatly trigger an LED.

Programming the Hello-Echo

My Boards and drawings in Eagle are not elegant, but I know that will come with time.

I made a lot of mistakes in developing these boards. I had to cut traces to re-run a wire. My button bridge VCC and Ground. This is not right. I don't know how that happened. I also did not catch this until the board was milled. (Note: Check the Traces after designing and before milling.) I cut the wire and soldered a jumper to pin 2(A3/Out3).
Furthermore,the output led is tied to RST. Rookie mistake. That pin is not an output. I cut that trace and tied a jumpter from the led pad to Pin 7(Out3,A1).
One big lesson learned: check the pin output. I have used RST when I shouldn't. I have tied Analog inputs to pins that do not read Analog.


        //adapted from Example Code(Tom Igoe)
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 1;     // the number of the pushbutton pin
const int ledPin =  0;      // the number of the LED pin not responsive to button
const int ledPin2=  2;     // the number of the LED pin tied to button
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin2, OUTPUT);
   pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT); //sets button to input
  digitalWrite(ledPin, HIGH);  //turns on LED 1(n
void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin2, HIGH); //turn on one led
  } else {
    // turn LED off:
    digitalWrite(ledPin2, LOW);

Attempt 3: Hall Sensor

  • The board was designed with Eagle.
  • Some changes to the traces were made using CorelDraw
  • The board was milled with Carvey milling machine using FabModules

  • The PNG image was put into FabModules-->PCB Traces-->Generate GCODE.
    The GCODE heading was edited to work with Carvey.
  • Board was soldered: Adding a Hall Effect Sensor..
  • Board programmed
  • Processing Code written to display data
  • Board/Program was tested - Success!
  • The board worked out okay. One mistake. I tied the Analog input to pin 0(PWM) not Analog. Since that pin is tied to MOSI on the 6-pin header. I soldered a pin onto pin 3(A2). This allowed me to send a signal to that pin.

    Code for the MagSensor Board:
                    // Code sample frome Analog Out example in Arduino IDE (Tom Igoe)
                    /*Modifications Dconner June 2016
                    * Turned Serial to Software serial
                    // These constants won't change.  They're used to give names
                    // to the pins used:
                    const int analogInPin = A2;  // Analog input pin that the potentiometer is attached to
                    const int analogOutPin = 2; // Analog output pin that the LED is attached to
                    int sensorValue = 0;        // value read from the pot
                    int outputValue = 0;        // value output to the PWM (analog out)
                    const int rx=3;
                    const int tx=2;
                    SoftwareSerial mySerial(rx,tx);
                    void setup() {
                    // initialize serial communications at 9600 bps:
                    void loop() {
                    // read the analog in value:
                    sensorValue = analogRead(analogInPin);
                    mySerial.print("out = ");
                    // wait 2 milliseconds before the next loop
                    // for the analog-to-digital converter to settle
                    // after the last reading:

    Using Processing to Read Data

    I created a simple code to display magnetic field strength. The detector has an equilibrium output of 510. A North and South magnetic field produces results that either go below that value or above that value. The graph is a small bar in the center of the screen. It grows to the right and to the left depending on the magnitude and direction of the field.


                 //Code based on SimpleRead Example in Processing
    //Edit by D Conner 2016
    import processing.serial.*;
    Serial myPort;  // Create object from Serial class
    int val;      // Data received from the serial port
    void setup()
      size(1020, 400);
      String portName = Serial.list()[2];// Port 2 is Com 3 on my computer
      myPort = new Serial(this, portName, 9600);
      val =510;//The sensor has an average initial value of 510.(Max is 1024, so this is almost half.)
    void draw()
      if ( myPort.available() > 0) {  // If data is available,
        String r = myPort.readString();//Read in a string
        String[] outputValues = split(r, " = ");//The expected input is "Out = 'value'"
        if(outputValues.length>1){  //Ensure the data has the Out value
           try {
          int n = Integer.parseInt(outputValues[1].trim());//Check to see if input is a integer.
            val = n;
           } catch(NumberFormatException e) {}
    }//If statement(port available)
      background(255);             // Set background to white
      if (val > 510) {              // If the value is greater than 510, color bar green
        rect(510, 50, val-510, 100);// make a bar that is the magnitude of the strength
      else {                       // If the value is less than 510, color bar red. Draw bar equal in magnitude.
          rect(val, 50, 510-val, 100);


    Blink Code
    MagSensor Code
    Processing Readout

    First Hello Button Board Schematic
    Hall Effect Board Schematic