Thursday, January 3, 2019

How to use 7 segment display with Arduino?

In this post, you’ll see how it’s so easy to drive a seven segment display with an Arduino board.


The seven segment display is simply a group of seven LEDs connected together and placed inside a nice enclosure to give the shape of a number when those LEDs are illuminated with a certain combination.



Components you need

7 segment display

Arduino UNO or Arduino Mega or Arduino Micro

Some wires



Circuit



Code


void setup()
{
  // define pin modes
 pinMode(2,OUTPUT);
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(8,OUTPUT);
 }
void loop() 
{
  // loop to turn leds od seven seg ON
   for(int i=2;i<9;i++)
  {
    digitalWrite(i,HIGH);
    delay(600);
  }
  // loop to turn leds od seven seg OFF
  for(int i=2;i<9;i++)
  {
    digitalWrite(i,LOW);
    delay(600);
  } 
  delay(1000);
}

This shows how it's so easy to interface a seven segment display to the Arduino board.

Read this article on AeroArduino.com

Source:
https://www.allaboutcircuits.com/projects/interface-a-seven-segment-display-to-an-arduino/


Wednesday, January 2, 2019

The easiest way to drive a relay with Arduino

Arduino became the standard as a platform for beginners and hobbyists for learning embedded development.

In many cases we need to control devices that drive larger currents like lamps, large motors or even home appliances.

When we control such devices with Arduino, we need some interfacing components called relays.

Relays play an important role in interfacing between light current control circuits and larger current devices.

They simply comprise a coil that can withstand large flow of current that can drive comparably large devices. Yet this coil can be controlled using simple controlling circuits.


Here is the easiest circuit and guide to drive a relay with Arduino.

While the current required for coil control is small but it cannot be connected to Arduino directly.

Arduino ports can supply up to 35 mA only. And relay coil can draw up to 100mA which can damage Arduino board.

To overcome this situation, we use a transistor as a switch that can be used to control the coil of the relay without damaging Arduino board.


Let’s see how this is done.



Components


Arduino

Relay

2N2222 transistor

Diode

Some wires

1K ohm resistor



Circuit



Arduino Code







Read this article on AeroArduino.com

Tuesday, January 1, 2019

How to blow an LED like a candle – LED as a temperature sensor

We’ve seen before how an LED can be used as a light sensor that senses how much light on it and then it can respond to this light intensity as a sensor and then reading this response with an Arduino.

Today we are checking this cool project of using Arduino with an LED as a temperature sensor that senses when it has been blow at and turns on and off.

What you need

Arduino

LED

220 ohm resistor

Some small wires

Circuit connection






Software


// Blow Out LED Ave creates an LED that you can blow out. It automatically relights after 2 seconds
//
// Copyright 2018, Paul H. Dietz

// LED Connections
#define PLUS A1               // High side of the resistor
#define MEASURE A0            // Low side of resistor and anode of LED
// Cathode of LED goes to ground

#define NUMSAMPLES 10         // Number of samples to keep
#define MINJUMP 150           // Minimum jump for blow out

long int sensedata[NUMSAMPLES];
int dataptr = 0;
int buffull = 0;

void setup() {
  Serial.begin(250000);                     // Initialize serial communication
  pinMode(MEASURE, INPUT);
  pinMode(PLUS, OUTPUT);
  digitalWrite(PLUS, HIGH);                 // Turn on the LED
}

void loop() {
  int cnt;
  long int sum = 0;

  // Sum 256 adc readings (to reduce adc noise)
  for (cnt = 0; cnt < 256; cnt++) {
    sum = sum + analogRead(MEASURE);
  }
  
  Serial.println(sum);                      // Output sum so we can watch with Serial Plotter

  // Compare current measurement to oldest if buffer full
  if (buffull && (sum > (sensedata[dataptr] + MINJUMP))) {
    // Temperature drop exceeded minimum - turn off
    digitalWrite(PLUS, LOW);
    dataptr = 0;                            // Reinitialize the buffer
    buffull = 0;
    delay(2000);                            // off time for LED
    digitalWrite(PLUS, HIGH);
  }
  else {
    sensedata[dataptr] = sum;               // Store the latest data in the buffer
    dataptr++;                              // Update buffer pointer
    if (dataptr == NUMSAMPLES) {            // Check if dataptr went past end
      dataptr = 0;                          // Reset the dataptr to beginning
      buffull = 1;                          // Mark that buffer is full
    }
  }

}



Testing




Source:

https://www.instructables.com/id/An-LED-You-Can-Blow-Out-Like-a-Candle/





Thursday, October 25, 2018

Arduino Cricket - How to generate soothing realistic Cricket Sounds with Arduino

The cricket is a little bug that makes noisy sounds at night.




Some people find them annoying. But some others - and I’m one of them - find them soothing and a symbol of nature and piece.

I admit that this repeatable sound of cricket can be annoying. It might get you sleep deprivation specially if it keeps making this noise in a place near where you sleep.

But the other type of people who find its sound soothing may be grateful to hear it at bedtime and feel relaxed from it.


There are even some iPhone and Android apps that do nothing but playing those sounds to keep you relaxed.

Today I thought of generating these sound using Arduino for fun.

This can be a good way of relaxation and you don’t need to go look for that cricket if you want it to stop. In this case you can simply turn it off. 

After all you are who programmed it.

I found a good post from a cleaver guy who made the most annoying cricket sound ever.

He wanted to make it a prank for his friend that he made the sound generation at random intervals.

He also made a consistent version of sound that sounded just like the normal cricket does.

In this version you can control the volume using PWM Pulse Width Modulation.

I liked the consistent sound version.


So here is how I made it.






What you’ll need:


  • Arduino board.
  • 8 ohm speaker.
  • Wires to connect the speaker to Arduino board.

Program the software

Circuit




Connect the speaker




Play the sound of your cricket.

That’s all.

Thank you for reading.


Code

#include "Volume3.h"
#define speakerPin 9

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  chirpFade();
  delay(random(100,5000));
}

void chirpFade() {
  uint16_t f = 3900;

  uint8_t times = random(1,3);
  float master = 1.0;
  uint16_t v = 0;
  uint8_t vDir = 1;
  float vb = 0;

  while (times > 0) {
    while (vb < 1.0) {
      if (v < 1023 && vDir == 1) {
        v += 16;
      }
      else {
        vDir = 0;
      }

      if (v > 0 && vDir == 0) {
        v -= 16;
      }
      else {
        vDir = 1;
      }

      vol.tone(speakerPin, f, v * constrain(vb, 0.0, 1.0)*master);
      delayMicroseconds(50);
      vb += 0.003;
    }
    while (vb > 0.0) {
      if (v < 1023 && vDir == 1) {
        v += 16;
      }
      else {
        vDir = 0;
      }

      if (v > 0 && vDir == 0) {
        v -= 16;
      }
      else {
        vDir = 1;
      }

      vol.tone(speakerPin, f, v * constrain(vb, 0.0, 1.0)*master);
      delayMicroseconds(50);
      vb -= 0.001;
    }
    times--;
    master -= 0.75;
  }
  vol.noTone();

}


Source

https://github.com/connornishijima/arduino-volume1/tree/master/examples/volume_crickeduino_prank

Tuesday, October 23, 2018

Arduino Ladder Logic - How to program Arduino like PLC using Ladder Logic

I've posted an article about Arduino based PLC and I've an unexpected response.

Many Arduino enthusiasts and students and also many other automation specialists showed interest to the subject.

This simply shows how there are so many people wanting to know more about open source and freely developed tools that can be used in automation and in industry as a whole.

I remember a friend of mine who had a dream since fourteen years ago. That dream he had was to replace old PLCs with modern Microcontrollers like PIC, Atmel and lately Arduino.

I guess now his dream came true.

I received a lot of questions on Arduino based PLC products and how they can be programmed.

So I’ve searched further and found that there are already some tools that can be used to program Arduino using ladder language.

PLCs are often programmed in ladder logic. This is because PLCs originally replaced relay control systems, and after all those years, we still haven't quite let go. A PLC, like any microprocessor, executes a list of instructions in sequence.


Today I’m putting these tools in front of you so you can start learning them and hopefully using them efficiently.


SoapBoxSnap


SoapBox Snap is a free and open source PC-based automation platform.

The ladder editor includes standard instructions like contacts, coils, timers, counters, rising edge and falling edge, and set/reset instructions.

SoapBox Snap also comes with an Arduino Runtime, which means you can download your ladder logic programs to an Arduino (UNO, Nano or Mega board) and even do online debugging and forcing.





LDmicro

It’s a compiler that starts with a ladder diagram and generates native PIC16 or AVR code.
Features include:

-       digital inputs and outputs
-       timers (TON, TOF, RTO)
-       counters (CTU, CTD, `circular counters' for use like a sequencer)
-       analog inputs, analog (PWM) outputs integer variables and arithmetic instructions
-       easy-to-use serial communications, to a PC, LCD, or other device
-       shift registers, look-up tables
-       EEPROM variables, whose values are not forgotten when you lose power
-       simulator, to test your program before you generate PIC/AVR code
http://cq.cx/ladder.pl

I hope this article could shed some light on the subject.

Thank you for reading.

Monday, October 22, 2018

Arduino based PLC - Where Arduino Meets Industrial Applications

Some people still think about Arduino and open source electronics as a toy for hobbyists and students.

We believe that open source hardware is in the process of revolutionizing electronics and industry in all fields of our lives.

Arduino and its shields have matured to be a modern way of researching tool, rapid prototyping and even in the field equipment for many industries.


M-DUINO PLC Arduino 57AAR I/Os Analog / Digital / Relay PLUS


Ease of use has made Arduino a good candidate for many applications. The variety of tools and millions of lines of code have facilitated the process of development.

Abundant sensors and massive processing power have found their way in Internet of Things era.

Collaborating with Big Data to collect huge amounts of bits of data to form useful information that lead to giant knowledge base for decision making on larger scales; Arduino is the heart for this big picture.


Odoo image and text block

Source: industrialshields.com

Today you can find weather monitoring stations completely built around open source hardware using open source tools for competitive prices.







Many companies are forming around Arduino platform to evolve into industrial automation makers.

To name some:

industrialshields.com is making its own industrial Arduino PLC and shields to control water level in tanks, production lines and weather station monitoring systems.

sferalabs.cc is making industrial enclosures for Arduino kits and shields for robustness.

If you are interested in Arduino, you can start by learning how to build your own industrial application.




Monday, October 15, 2018

Arduino Drawing Robot - How to do Art with Arduino and a Pen

In this post will see how this Arduino controlled robot can make beautiful patterns and drawings.




Gathering Parts




Arduino Uno
2 5v Stepper Motors
Micro Servo
ULN2803
Breadboard


Code
You can get the code from here.





Making the frame





Circuit diagram

Installing Wheels





Mounting Servo for Pen movement





Final Assembly and Test




Source
https://www.instructables.com/id/Arduino-Drawing-Robot/