Posts

Lab #5: Bio-Signals

Image
ECG Tutorial Heart rate from ECG in Arduino - sketch that acquires the ECG signal via one of the analog inputs #include "Wire.h" #include "Adafruit_LiquidCrystal.h" Adafruit_LiquidCrystal lcd(0); int pin = A0; int count = 0; void setup() {   Serial.begin(9600);  // put your setup code here, to run once:   pinMode(pin, OUTPUT);   lcd.begin(16,2); } void loop() {   // put your main code here, to run repeatedly: int now = millis(); while (millis() - now < 10000) {   int sensorValue = analogRead(pin);   Serial.println(sensorValue);   if (sensorValue > 116) {     count++;   }   }   int printed = count*6;   lcd.print(printed);   lcd.print("bpm");   delay(300);   lcd.clear();   count = 0; } - devise a procedure to calculate the heart rate from the acquired ECG signal - send the heart rate to the LCD Pulse Sensor Here is a screenshot of what the Pulse S...

Lab #6: Wireless Lab - IR and WiFi

Image
IR Receiver Our results printed to the Serial monitor after pressing 1, 2, and 3 on the remote. 1 - C9767F76 2 -C8155AB1 3 - B6996DAE 4 - 969AE844 5 -4AAFAC67 6 - 9C2A936C 7 - 833ED333 8 - 55F2B93 9 -DE78B0D0 0 -F32F72D7 Code for IR Receiver #include <IRremote.h> int RECV_PIN = 11; //IR Receiver connected to pin 11 int yellow = 3; int green = 4; IRrecv irrecv(RECV_PIN); decode_results results; void setup() {   Serial.begin(9600);   irrecv.enableIRIn(); // Start the receiver pinMode(yellow, OUTPUT); pinMode(green, OUTPUT); } void loop() {   results.value = 0x00;   if (irrecv.decode(&results)) { //if a code received     Serial.println(results.value, HEX); //displays in hexidecimal format    //pressing 1 on remote    if(results.value == 0x...

Lab #4: Non-volatile memory, Servo Motors and MATLAB

Image
Build a data-logger with a photoresister Below is our code for the data logger with a photoresistor: #include <EEPROM.h> int pin = A0; int index = 0;   void setup() {   // put your setup code here, to run once: Serial.begin(9600); pinMode(pin,INPUT); Serial.println("Input 'W' to write data into EEPROM. Input 'R' to read data."); } void loop() {   // put your main code here, to run repeatedly: char inputChar = Serial.read(); if (inputChar == 'W'){   for(index; index <13; index ++){     int data = analogRead(pin);     EEPROM.write(index, data);     index ++;     delay(5000);       }   index = 0;      }else if (inputChar == 'R'){   int i = 0;   while (i <13){     int value = EEPROM.read(i);  ...

Lab #3: ColorPAL

Image
Use Serial.read() to control the Arduino We learned we needed to enter or "send" the data to the serial monitor each time we input new data. Play Notes on the Arduino int inputChar; void setup () { pinMode(12,OUTPUT); Serial.begin(9600); } // this code will play the A major scale which has 3 sharps, C#, F#, and G# void loop(){ if (Serial.available() > 0) { inputChar = Serial.read(); if (inputChar == 'a'){ tone(12,1760); } if(inputChar == 'b'){ tone(12,1976); } if(inputChar == 'c'){ tone(12,2216); } if(inputChar == 'd'){   tone(12,2348); } if(inputChar == 'e'){   tone(12,2636); } if(inputChar == 'f'){   tone(12, 2960); } if(inputChar == 'g'){   tone(12, 3324, 400); } } } Above is the code we used to play different tones corresponding to an A major scale. We used a Piezo buzzer and had the same circuit set-up as in previous labs. Create some LED flashing r...

Lab #2: Analog Inputs and Outputs

Image
Lab 2: Analog Inputs and Outputs This second lab had us using analog inputs and outputs, such as sound, and we then were able to start developing more complex medical devices.  Generating Signals Inside the Microcontroller Ramp Output The code we wrote to create a ramp output function. We used the modulus function so that whenever our variable "counter" reached 100, the variable would drop to 0 and then start counting again. We added a delay of 50 milliseconds just so that the Serial Monitor would be legible. Using the Serial Monitor proved to not be a good visual when looking at our ramp output. While you can see our function worked, it is hard to visualize. Above is a screenshot of the Serial Plotter to better visualize the ramp output function. Sine Wave The sine wave generated on the Serial Plotter. Make Some Noise - Analog Output Fritzing of the circuit with the Piezo buzzer with 100k Ohm resistor Our code for the ...

Lab #1: Arduino Basics

Image
The first lab was to get us acclimated to Arduino and provide us with the foundations to start developing medical devices. Part 1: The first part of this lab was simply downloading the program and then mounting the LCD to a "backpack" so that building a circuit with the LCD would not be a mess of wires every time we used it. Mounting the LCD to the backpack involved some soldering - which was a little hard to get used to! The LCD mounted onto the backpack. As you can see, there are only 4 wires required to connect to the Arduino.  The underside of the LCD. If you look closely, you can see the great job Maddie did at soldering. Part 2 Serial Output:  This portion of the lab introduced us to "sketches" and how Arduino libraries work. This is necessary for later when we need Adafruit.LiquidCrystal to use the LCD screen. The first coding we did involved printing a phrase to the Serial Monitor. Then, we moved onto using variables - stil...