Tuesday, May 15, 2018

Meet Pinguino - PIC based Arduino compatible DIY board

If you came to this post then you probably are an Arduino enthusiast and you want to make your own Arduino.


There are many Arduino compatible boards out there.


In this list you can find many Arduino compatible circuits and projects that are Atmel and Non-Atmel based.

In this post, I'll show you an Arduino code compatible project that is based on PIC Microcontroller.

Pinguino is a project based on PIC Microcontroller from Microchip Manufacturer.


I'm a big fan of PIC microcontroller long before I knew Arduino. So once I knew about Pinguino I got excited to build it.


It supports a wide range of Microcontrollers including 8 and 32 Bits.

It has its own IDE but it's code compatible with Arduino.

This means that you can use the code written for Arduino in your own Pinguino projects.

Components


Connections




Circuit

Steps

You can find detailed instructions of how to build this circuit step-by-step on my instructables page and on my blog.

https://www.instructables.com/id/Pinguino-Egypt-PIC-Based-Arduino/ 

http://embedded-egypt.blogspot.com.eg/2014/02/pinguino-egypt-do-it-yourself-pic.html







Source: My Instructables Page


Sunday, May 13, 2018

Arduino IR Heart Rate Monitor - How to measure your heart rate using Arduino and simple electronics

Today I found a simple circuit that uses Arduino and simple electronic components to measure and visualize heart rate.



There are many circuits out there that uses Arduino boards and a special heart rate sensor.

Although I don't yet know the idea behind that heart rate sensor but I think it could be simple.

That's why I searched further until I could find this simple circuit in this post.

This circuit is so simple that it only contains Arduino board and IR transmitter and receiver as the heart rate sensor.

I know this is very simple and primitive, but it's efficient.

You can find many circuits with expensive sensors or larger circuits that use many amplifiers and OP-AMPs.

But this one is fairly simple and enough for the job.


Theory of operation
The IR (infrared) transmitter and receiver are used to measure the blood flow which corresponds to the heart rate.

The Arduino processor then processes the received signal and filters it to get a cleaner indication of the heart rate based on the blood flow in your finger.



Components
Arduino Uno 
IR emitter and detector
100 Ohm resistor
10K Ohm resistor



Connections



Circuit


Code

Arduino Code

#include
#include
#include
#include
#include
#include

float amplifiedSignal;
float filteredSignal;

void setup() {
  Serial.begin(9600);
}


// filter out frequencies below 1 Hz.
float highFilterFrequency = 1;  

// create a highpass filter that only keeps frequencies above highFilterFrequency
FilterOnePole filterOneHighpass( HIGHPASS, highFilterFrequency );  

// filters out frequenceies greater than 3 Hz.
float lowFilterFrequency = 3;  

// create a lowpass filter that only keeps frequencies below lowFilterFrequency
FilterOnePole filterOneLowpass(LOWPASS, lowFilterFrequency);  


void loop() {
  
//The next line applies a band pass filter to the signal

  amplifiedSignal = 100*analogRead(A0);
  filteredSignal = filterOneHighpass.input(filterOneLowpass.input(amplifiedSignal));

  Serial.println(filteredSignal);



}


Processing code

import processing.serial.*;

Serial myPort;        // The serial porthe
int xPos = 1;         // horizontal position of the graph 

//int xPos = millis()/1000;

//Variables to draw a continuous line.
int lastxPos=1;
int lastheight=0;

int screenWidth = 600;
int screenHeight = 400;

int pulseNumber = 0;
boolean pulseHigh = false;
int startTime;
int stopTime;
int heartRate;

void makeGrid(int screenWidth, int screenHeight){
  stroke(0,255,0);
  strokeWeight(0.5);
  line(0, screenHeight/2, screenWidth, screenHeight/2);
  
  for (int i = 0; i <= 10; i = i+1) {
    line(i*screenWidth/10, 0, i*screenWidth/10, screenHeight);
    line(0, i*screenHeight/10, screenWidth, i*screenHeight/10);
  }
}

void setup () {
  // set the window size:
  size(screenWidth, screenHeight);        

  // List all the available serial ports
  println(Serial.list());
  // Check the listed serial ports in your machine
  // and use the correct index number in Serial.list()[].

  myPort = new Serial(this, Serial.list()[0], 9600);  //

  // A serialEvent() is generated when a newline character is received :
  myPort.bufferUntil('\n');
  background(0);      // set inital background:
  
  makeGrid(screenWidth, screenHeight);
   
  
}
void draw () {
  // everything happens in the serialEvent()
}



void serialEvent (Serial myPort) {
  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');
  if (inString != null) {
    inString = trim(inString);                // trim off whitespaces.
    float inByte = float(inString);           // convert to a number.
    
    if (inByte >= 0 && pulseHigh == false){
      if (pulseNumber == 0){
        startTime = millis();
        //println("first");
      }
      else{
        stopTime = millis();
      }
      pulseNumber = pulseNumber + 1;
      //println("next");
      pulseHigh = true;
    }
    
    else if (inByte <= 0 && pulseHigh == true){
      pulseHigh = false;
    }

    
    
    inByte = map(inByte, -1023, 1023, 0, height); //map to the screen height.
    
    //Drawing a line from Last inByte to the new one.
    stroke(255,0,0);     //stroke color
    strokeWeight(4);        //stroke wider
    line(lastxPos, lastheight, xPos, height - inByte); 
    lastxPos= xPos;
    lastheight= int(height-inByte);
    

    // at the edge of the window, go back to the beginning:
    if (xPos >= width) {
      xPos = 0;
      lastxPos= 0;
      background(0);  //Clear the screen.
      makeGrid(screenWidth, screenHeight);
      
      heartRate = 60*1000*(pulseNumber-1)/(stopTime-startTime);
      textSize(16);
      //text("This is your heart beat. Your heart rate is " + str(heartRate) + " bpm.", 10, 30); 
      //fill(0, 102, 153);
      
      pulseNumber = 0;
    } 
    else {
      // increment the horizontal position:
      xPos++;
    }
  }

}



Results






Source: Instructables


















Arduino Permanent Memory - How to use Arduino EEPROM Memory

Have you ever built an embedded system and wanted to store memory that lasts after you switch off the power of the system?

Arduino boards is based around the AVR microcontroller that has built in EEPROM memory which is not volatile after you switch off the power of the circuit.

This means that you don't need any external hardware or ICs when you need to store some small amount of data or system settings.

Circuit

When you test this code you only need Arduino UNO board as your circuit.


Code

#include

void setup()
{
  for (int i = 0; i < 255; i++)
    EEPROM.write(i, i);
}

void loop()
{
}

Source: Arduino Website

Friday, May 11, 2018

How to make an Arduino Tide Clock for Marine Life Simulation

Tide clock is a clock that displays times to/past high and low tides instead of displaying real time.

Image result for Tide clock


Inspired by the marine life, today I found a project that uses Arduino to simulate high and low tides into an artificial environment for marine life simulation.

The project has both electronic and mechanical parts.

The electronic part features Arduino and a real time clock to calculate tide times.

The three components of my simple tide clock from left to right: Arduino Pro Mini 3.3V (red), Real Time Clock (blue), SSD1306 OLED display.



While the mechanical part features parts that control water flow and level into the artificial marine life environment.

Functional diagram and illustration of the tide height control system.




Source: PeerJ


Saturday, May 5, 2018

Arduino Train - How to make an Arduino Controlled Model Train

In this post I found this instructable that makes a beautiful yet easy useful toy for your kids.

Today I found an Arduino controlled model train that you can move using your phone.




We have seen how it's so easy to control devices using Arduino and Bluetooth module.





This projects implements that idea.

It uses Arduino Nano as a controller and HC-06 Bluetooth module to connect to the smartphone.

Then the train is driver by the L293D H-Bridge.





Components
Arduino Nano
HC-06 Bluetooth Module
L293D H-Bridge

Connections


Picture of Simple Start
Circuit
Picture of Simple Start








Code

// ARDUINORAILMAKET.RU
// SimpleСmdStation.ino
// 05.02.2017
// Author: Steve Massikker

//// GPIO PINS ////

// L298
#define ENA_PIN 3
#define IN1_PIN 4
#define IN2_PIN 5

//// VARIABLES ////
boolean stringComplete = false;
String inputString = "";


void setup() {
  
  // Initialize Serial
  Serial.begin(9600);
  inputString.reserve(16);
  
  // Initialize Motor Driver
  pinMode(ENA_PIN, OUTPUT);
  pinMode(IN1_PIN, OUTPUT);
  pinMode(IN2_PIN, OUTPUT);

}

void loop() {

  if (stringComplete) {

    // ----------- START COMMAND PARSING ----------- //
    
    //THROTTLE
    
    if (inputString.charAt(0) =='t') {
      if (inputString.charAt(1) =='0') {
        analogWrite(ENA_PIN, 0);
      }
      if (inputString.charAt(1) =='1') {
        analogWrite(ENA_PIN, 80);
      }
      if (inputString.charAt(1) =='2') {
        analogWrite(ENA_PIN, 100);
      }
      if (inputString.charAt(1) =='3') {
        analogWrite(ENA_PIN, 150);
      }
      if (inputString.charAt(1) =='4') {
        analogWrite(ENA_PIN, 200);
      }
      if (inputString.charAt(1) =='5') {
        analogWrite(ENA_PIN, 255);
      }
    }

    // DIRECTION

    if (inputString.charAt(0) =='d') {
      if (inputString.charAt(1) =='r') {
        digitalWrite(IN1_PIN, HIGH);
        digitalWrite(IN2_PIN, LOW);
      }
      if (inputString.charAt(1) =='f') {
        digitalWrite(IN1_PIN, LOW);
        digitalWrite(IN2_PIN, HIGH);
      }
      if (inputString.charAt(1) =='s') {
        digitalWrite(IN1_PIN, LOW);
        digitalWrite(IN2_PIN, LOW);
        analogWrite(ENA_PIN, 0);
      }
    }

    //TEST

    if (inputString.charAt(0) =='j') {
      if (inputString.charAt(1) =='a') {
        digitalWrite(LED_BUILTIN, HIGH);
      }
      if (inputString.charAt(1) =='b') {
        digitalWrite(LED_BUILTIN, LOW);
      }
    }

// ----------- END COMMAND PARSING ----------- //

inputString = "";
stringComplete = false;

  }
}

// ----------- FUNCTIONS ----------- //

void serialEvent() {
  while (Serial.available() ) {
    char inChar = (char)Serial.read();
    inputString += inChar;
      if (inChar == 'z') {
      stringComplete = true;
    }
  }
}








Source : Instructables

Thursday, May 3, 2018

Arduino standalone Audio generation - How to play Audio Signals from Arduino without modules using PCM signals

In this post we'll see how to generate audio signals from Arduino without using any shields or modules.

PCM (Pulse Code Modulation)



Using Arduino and a speaker, you can generate audio signals as if they were coming out from an MP3 player.


Components
Arduino Uno
8 ohm Speaker
TIP 120 Resistor to be used as an amplifier.

Circuit

Picture of Connections



Just connect the amplifier transistor to Arduino and then connect them to the speaker.

Software
Download Audacity and then download software encoder from here.


Arduino code is included in this file.








Source: Instructables

















Wednesday, May 2, 2018

How to make smaller Arduino Projects using 8-pin ATtiny chip

Have you ever made a project with Arduino and you loved it very much?



Have you ever felt for some project that it deserves to be built on a decent PCB, packaged in a robust enclosure and shown to the whole world?

You may be an Arduino enthusiast and try a project everyday with your favorite board.

But hey ... You only have this single Arduino board that you got for $10 and you still want to try all those projects.

You also have to make all those jumper wires look like spaghetti.

What's the solution for this situation?
 The only solution for this is first by trying your design and prototyping it on your normal Arduino board.

And then after the designing and refining process you transfer your design to a practical circuit using normal electronics based on the code you've just developed.

So how can you use your Arduino code developed for Arduino Uno board of $10 to those ATtiny chips coasting $2?

Here is the solution.

In this post you'll learn how to load Atiny with Arduino code using Arduino board as a programmer.
This is very cool and has many advantages...

1 .You make your design more cost effective as you are using lower priced chips(if you already need only short number of input output pins.

2 .Your design is size efficient as you make it smaller and more practical.

3 .Your design becomes permanent on its own PCB.

4 . No need for new code or software as you are already using code you've just developed for Arduino board.

5 . No need for special programming circuits and loaders as you use only Arduino board as a programmer and Arduino IDE as the software loader.

So let's see how this is done.

This project is based on the High-Low Tech Program tutorial from MIT that describes in detail how to program ATtiny 45/85 with Arduino.


Circuit







Source: Makezine