Document

Input Devices



Individual assignment

For this week individual assignment I use the switch as an input device follow the Neil´s hello.button.45 example. Then I design my board using KiCad.




I use de Roland Modela MDX 20 for make the PCB and the online Mods as a controller.



I forgot to put one trace so I had to place an improvised wire.


Since I finish of soldering the PCB I was traying to program it, use first Arduino IDE but when I was loading the program on the board send an error, and I assumed it was a configuration or programming problem, I switched to Atmel Studio 7. After trying several hours without success, I went back to review the board and found that it was not I had printed a track. Then I could program the board and run it in Arduino IDE, but not in Atmel Studio 7.


For coding in Arduino IDE and then load the code at Attiny family, like here, is necessary to use the SoftwareSerial librarie (Using software serial allows you to create a serial connection on any of the digital i/o pins on the Arduino. This should be used when multiple serial connections are necessary. If only one serial connection is necessary the hardware serial port should be used) unlike when using arduino hardware (like Arduino Uno) that does not need the use of this library. In this case the serial conection is beetwen the PC and the chip through the FTDI cable.

The code:


#include 

int buttonPin = 4;
int buttonPushCounter = 0;   
int buttonState = 0;         
int lastButtonState = 0;     

SoftwareSerial mySerial(11, 2); // RX, TX 

void setup() {
							  
pinMode(buttonPin, INPUT_PULLUP);
							  
}
							  


void loop() { 
mySerial.begin(9600);
buttonState = digitalRead(buttonPin);

if (buttonState != lastButtonState) {
							   
if (buttonState == HIGH) {
							      
buttonPushCounter++;
mySerial.write("u");
							   
} 
else {
							      
mySerial.write("d");
							      
}
							    
delay(50);
}

lastButtonState = buttonState;

}

Sonar - movement/distance sensor

(Actualization)


For my final project I use the Ultrasonic Ranging Module HC - SR04. Click here to see this work.


Group assignment





Asignment goals

  • Measure the analog levels and digital signals in an input device (group assignment).
  • Measure something: add a sensor to a microcontroller board that you have designed and read it.





























































































































































































Downloads:

All Files