Week 3 - Circuit Board Design

Eagle Circuit Design

Circuit Schematic

This design was determined roughly based on the tutorial for homemade hardware and exploring the design in the prototyping phase as outlined in Appendix 1

image

Board Layout

Imported an SVG I designed in Illustrator for the board and then used auto routing to decide wiring scheme.

image

Appendix I - Designing The Circuit & Code

Prototyping the circuit board

image

Arduino Code

Uses the Capacitive Sensor Library by Paul Badger

#include <CapacitiveSensor.h>

// 10M resistor between pins 2 & 0, pin 0 is sensor pin, add a wire and or foil
CapacitiveSensor   cs_2_1 = CapacitiveSensor(2, 1);
long fadeSpeed = 5;

void setup()
{
  // Set output pins
  pinMode(4, OUTPUT);

  // Idk why this is being done here
  cs_2_1.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
}

void loop()
{
  long start = millis();
  long sensorValue = cs_2_1.capacitiveSensor(30);
  long total =  map(sensorValue, 0, 256, 0, 1) == 0 ? LOW : HIGH;

  
  if (total == HIGH) {
    fadeSpeed = 50;
  } else {
    fadeSpeed = 5;
  }
  
  for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += fadeSpeed) {
    // sets the value (range from 0 to 255):
    analogWrite(4, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }

  // fade out from max to min in increments of 5 points:
  for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= fadeSpeed) {
    // sets the value (range from 0 to 255):
    analogWrite(4, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
  
  
  delay(10);                             // arbitrary delay to limit data to serial port
}