top of page

Search Results

81 items found for ""

  • Interfacing of Force Pressure Sensor with Arduino Uno.

    Back Interfacing of Force Pressure Sensor with Arduino Uno. What is a Force Pressure Sensor? An FSR (Force Sensitive Resistor) or Force Pressure Sensor is a sensor that allows you to measure physical pressure, weight and squeezing. The resistance of an FSR varies as the force on the sensor increases or decreases. When no pressure is being applied to the FSR, its resistance will be larger than 1MΩ. The harder you press on the sensor’s head, the lower the resistance between the two terminals drops. By combining the FSR with a static resistor to create a voltage divider, you can produce a variable voltage that can be read by a microcontroller’s analog-to-digital converter. Material Required: Material Quantity Arduino Uno 1 Force Pressure Sensor 1 Jumper cables 4 LED 1 Resistor 1 ( 10 k) Pinout Diagram: Circuit Diagram: The connections are pretty easy and straight forward. Make the circuit by referring the images. The FSR has two pins, one will be connected to 5V pin. The other to A0 directly and to Gnd pin via a resistor. If you need to connect the LED and control it's brightness, then connect it across pin 13 and Gnd of the Arduino. Tested Programming Code: int fsrPin = 0; // the FSR and 10K pulldown are connected to a0 int fsrReading; // the analog reading from the FSR resistor divider void setup(void) { Serial.begin(9600); } void loop(void) { fsrReading = analogRead(fsrPin); Serial.print("Analog reading = "); Serial.print(fsrReading); // the raw analog reading if (fsrReading == 0) { Serial.println(" - No pressure"); } else if (fsrReading < 10) { Serial.println(" - Light touch"); } else if (fsrReading < 50) { Serial.println(" - Light squeeze"); } else if (fsrReading < 150) { Serial.println(" - Medium squeeze"); } else { Serial.println(" - Big squeeze"); } delay(1000); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of Force Pressure Sensor for correct working. 5. Don’t lose hope if Force Pressure Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor. There you can see the Pressure applied on the sensor as Light , Big or No squeeze. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing 2 Channel Relay Module with Arduino and control High Voltage AC (current).

    Back Interfacing 2 Channel Relay Module with Arduino and control High Voltage AC (current). What is a Relay Module? A Relay is a device that helps microcontrollers (or microcontroller-based boards) like Arduino to switch on or off different household appliances like motors, lights, water heaters, television, fans, etc. The relay module for Arduino is one of the most powerful applications for Arduino as it can be used to control both A.C and D.C devices by simply controlling the relay by giving 5V. A relay is a switch that is operated electrically by an electromagnet. A relay can be used to control high voltage electronic devices such as motors as well as low voltage electronic devices such as a light bulb or a fan. Relays work on the principle of electromagnetism. When the electricity is provided to the relay coil then it acts like a magnet and changes the state of the switch. The part which powers the relay module is completely isolated from the part which turns ON or OFF. This is why we can control a 220V appliance by simply controlling it using the 5V Arduino. you should also read getting started projects of Arduino. Material Required: Material Quantity Arduino Uno 1 Relay module (2 Channel) 1 Jumper cables 6 Switching Source 1 Cable, Plug, Socket 1 Pinout Diagram: HL-52S Relay Module As an example, for this Arduino Relay Tutorial, we will use the HL-52S 2 channel relay module, which has 2 relays with a rating of 10A @ 250 and 125 V AC and 10A @ 30 and 28 V DC. The high voltage output connector has 3 pins, the middle one is the common pin, and as we can see from the markings one of the two other pins is for a normally open connection and the other one for a normally closed connection. On the other side of the module, we have these 2 sets of pins. The first one has 4 pins, a Ground and a VCC pin for powering the module, and 2 input pins In1 and In2. The second set of pins has 3 pins with a jumper between the JDVcc and the Vcc pin. With a configuration like this, the electromagnet of the relay is directly powered by the Arduino Board and if something goes wrong with the relay the microcontroller could get damaged. Circuit Diagram: For better understanding let’s see the circuit schematics of the relay module in this configuration. So we can see that the 5 volts from our microcontroller connected to the Vcc pin for activating the relay through the Optocoupler IC are also connected to the JDVcc pin which powers the electromagnet of the relay. So in this case we got no isolation between the relay and the microcontroller. To isolate the microcontroller from the relay, we need to remove the jumper and connect a separate power supply for the electromagnet to the JDVcc and the Ground pin. Now with this configuration, the microcontroller doesn’t have any physical connection with the relay, it just uses the LED light of the Optocoupler IC to activate the relay. There is one more thing to be noticed from this circuit schematics. The input pins of the module work inversely. As we can see the relay will be activated when the input pin will be LOW because in that way the current will be able to flow from the VCC to the input pin which is low or ground, and the LED will light up and activate the relay. When the input pin will be HIGH there will be no current flow, so the LED will not light up and the relay will not be activated. High Voltage Warning Before we continue with this tutorial, I will warn you here that we will use High Voltage which if incorrectly or improperly used could result in serious injuries or death. So be very cautious of what you are doing because I take no responsibility for any of your actions. How to use the relay module with the High Voltage devices First, let’s take a look at the circuit diagram. As previously described we will use a 5V Adapter as a separate power supply for the electromagnet connected to the JDVcc and the Ground pin. The Arduino’s 5V pin will be connected to the Vcc pin of the module and PIN 7 to the In1 input pin for controlling the relay. Now for the HIGH Voltage part, we need a power plug, a socket, and a cable with two wires. One of the two wires will be cut and connected to the common and the normally open pin of the module output connector. So with this configuration when we will activate the relay we will get the high voltage circuit closed and working. Here’s how made the cable. So I bought a plug, a socket, and a cable. Then I carefully cut the cable and cut one of the wires as shown in the picture below and connect them to the normally open connection pins of the relay module. Also connected the ends of the cable to the plug and the socket. Tested Programming Code: Now what’s left for this tutorial is to make a simple code and test the relay module and how it will work. Here’s the simple code, we will just use the PIN 7 for controlling the relay, so we will define it as output and make a program that will just activate and deactivate the relay every 3 seconds. I will mention once again here that the input of the module works inversely so a logic low at the input will activate the relay and vice versa. int in1 = 7; void setup() { pinMode(in1, OUTPUT); digitalWrite(in1, HIGH); } void loop() { digitalWrite(in1, LOW);delay(3000); digitalWrite(in1, HIGH); delay(3000); } There is a demonstration of this example at the end of the video of this tutorial. I tested 3 devices on it. First a 100W light bulb, then a desk lamp, and a fan heater. All of these devices work on 220V. Precautions: 1. Double-check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of Relay Module for correct working. 5. Use proper measures before using AC electricity. Conclusion: So that’s how we can control any High Voltage Device using Arduino or any other microcontroller. And of course, the possibilities are now endless, for example, we can control the devices using a TV Remote, Bluetooth, SMS, Internet, and so on. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth

    Back 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth Students now you know everything about how a matrix works, let’s move to some advanced part of it. 8×8 LED Matrix Scrolling Arduino Code Next let’s take a look at the scrolling text example and see what’s different. Below the code you will find its description. #include #include PROGMEM const unsigned char CH[] = { 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, //* 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, //A 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, //O 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, //h 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, //v 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ }; int DIN = 7; // DIN pin of MAX7219 module int CLK = 6; // CLK pin of MAX7219 module int CS = 5; // CS pin of MAX7219 module int maxInUse = 2; MaxMatrix m(DIN, CS, CLK, maxInUse); byte buffer[10]; char text[]= "TechKnowSkola"; // Scrolling text void setup() { m.init(); // module initialize m.setIntensity(15); // dot matix intensity 0-15 } void loop() { printStringWithShift(text, 100); // (text, scrolling speed) } // Display=the extracted characters with scrolling void printCharWithShift(char c, int shift_speed) { if (c < 32) return; c -= 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(32, 0, buffer); m.setColumn(32 + buffer[0], 0); for (int i = 0; i < buffer[0] + 1; i++) { delay(shift_speed); m.shiftLeft(false, false); } } // Extract the characters from the text string void printStringWithShift(char* s, int shift_speed) { while (*s != 0) { printCharWithShift(*s, shift_speed); s++; } } Now let’s move to the functioning of Bluetooth HC-05 Description: Here we have to include an additional library for the PROGMEN which is variable modifier and it’s used for storing data in the flash memory instead of SRAM. When we have a larger database of variables which are static, like in this case defining letters and characters, it’s better to store them in the flash memory because it’s much bigger, 32K bytes, compared to the 2K bytes of the SRAM. Next with a character array we define the scrolling text and in the loop section the custom function printStringWithShift, prints the scrolling text on the LED matrix with a scrolling speed defined in milliseconds with the second argument. The first thing that this custom function do is that it extracts the characters from the text string and then display these scrolling characters on the led matrix. The particular module that I have can be powered from 3.6 to 6 volts, because it comes on breakout board which contains a voltage regulator. However, the logic voltage level of the data pins is 3.3V. So, the line between the Arduino TX (Transmit Pin, which has 5V output) and the Bluetooth module RX (Receive Pin, which supports only 3.3V) needs to be connected through a voltage divider in order not to burn the module. On the other hand, the line between the Bluetooth module TX pin and the Arduino RX pin can be connected directly because the 3.3V signal from the Bluetooth module is enough to beaccepted as a high logic at the Arduino Board. Circuit Schematics: Here’s how we need to connect the module to the Arduino Board. Connecting the Smartphone to the HC-05 Bluetooth Module and the Arduino Now we are ready to connect the smartphone to the Bluetooth module and the Arduino. What we need to do here is to activate the Bluetooth and the smartphone will find the HC-05 Bluetooth module. Then we need to pair the devices and the default password of the HC-05 module is 1234. After we have paired the devices we need an application for controlling the Arduino. There are many application in the Play Store for this purpose which will work with the Arduino code that we wrote. However, I made my own custom application for this tutorial using the MIT App Inventor online application. This is a great and easy to use application for building Android application and in my next tutorial you can find a detailed step by step guide how to build your own custom Android application for your Arduino Project. Android App for Controlling 8×8 LED Matrix via Bluetooth Once we learned how the MAX7219 works, now we can make the third example which is a practical Arduino project where we will build a custom Android app to control the LED matrix via Bluetooth communication. Before we continue I would suggest you to check detailed tutorials on how to use the HC-05 Bluetooth module and how to build a custom Android app using the MIT App Inventor online application . Here’s the Arduino code and now let’s see the modifications compared to the previous example. /* 8x8 LED Matrix MAX7219 Scrolling Text Android Control via Bluetooth by Dejan Nedelkovsk i, www.HowToMechatronics.com Based on the following library: GitHub | riyas-org/max7219 https://github.com/riyas-org/max7219 */ #include #include #include PROGMEM const unsigned char CH[] = { 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, //# 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, //- 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, //; 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, //T 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, //b 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, //{ 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ }; int dIn = 7; // DIN pin of MAX7219 module int clk = 6; // CLK pin of MAX7219 module int cs = 5; // CS pin of MAX7219 module int maxInUse = 2; // Number of MAX7219's connected MaxMatrix m(dIn, cs, clk, maxInUse); SoftwareSerial Bluetooth(8, 7); // Bluetooth byte buffer[10]; char incomebyte; int scrollSpeed = 100; char text[100] = "TechKnowSkola "; // Initial text message int brightness = 15; int count = 0; char indicator; void setup() { m.init(); // MAX7219 initialization m.setIntensity(brightness); // initial led matrix intensity, 0-15 Bluetooth.begin(38400); // Default communication rate of the Bluetooth module } void loop() { // Printing the text printStringWithShift(text, scrollSpeed); if (Bluetooth.available()) { // Checks whether data is comming from the serial port indicator = Bluetooth.read(); // Starts reading the serial port, the first byte from the incoming data // If we have pressed the "Send" button from the Android App, clear the previous text if (indicator == '1') { for (int i = 0; i < 100; i++) { text[i] = 0; m.clear(); } // Read the whole data/string comming from the phone and put it into text[] array. while (Bluetooth.available()) { incomebyte = Bluetooth.read(); text[count] = incomebyte; count++; } count = 0; } // Adjusting the Scrolling Speed else if (indicator == '2') { String sS = Bluetooth.readString(); scrollSpeed = 150 - sS.toInt(); // Milliseconds, subtraction because lower value means higher scrolling speed } // Adjusting the brightness else if (indicator == '3') { String sB = Bluetooth.readString(); brightness = sB.toInt(); m.setIntensity(brightness); } } } void printCharWithShift(char c, int shift_speed) { if (c < 32) return; c -= 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(32, 0, buffer); m.setColumn(32 + buffer[0], 0); for (int i = 0; i < buffer[0] + 1; i++) { delay(shift_speed); m.shiftLeft(false, false); } } void printStringWithShift(char* s, int shift_speed) { while (*s != 0) { printCharWithShift(*s, shift_speed); s++; } } void printString(char* s) { int col = 0; while (*s != 0) { if (*s < 32) continue; char c = *s - 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(col, 0, buffer); m.setColumn(col + buffer[0], 0); col += buffer[0] + 1; s++; } } Description: First we need to include the SoftwareSerial.h library which will enable the Bluetooth communication and define some variables needed for the program. In the setup section we need to initialize the Bluetooth at its default baud rate of 38400 bits per second. I set the initial text message to be “TechKnowSkola” with 100 milliseconds delay scrolling speed. Next, in the loop section, using the Bluetooth.available() function we check whether there is incoming data from the serial port and if that’s true using the Bluetooth.read function we start reading the serial port, one byte each iteration. So the first incoming byte will be always stored into the “indicator” variable and according to it choose whether we will change the text message, the scrolling speed or the brightness of the LED matrix. If we take a look at the Android app code blocks we can notice that when the “Send” button is clicked, first we send the indication byte, in this case “1”, which means we want the change the text message. In order to do that, at the Arduino side, we will clear the whole character array and also clear the LED matrix display. Then in the “while” loop we will read the rest of the data in the serial port, and that’s the messaged typed in the text box of the Android app. In case the indication variable is “2”, that means we have changed the position of the scrolling speed slider, so we will read its new value using the Bluetooth.readString() function and adjust the scrolling speed. In the same way we adjust the brightness of the LEDs. You can download the app from the following link: https://drive.google.com/open?id=1xvR_tyTF-zzdrqc6RrdHlcD5FRICIbs5 Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of Sound sensor with Arduino Uno.

    Back Interfacing of Sound sensor with Arduino Uno. What is a Sound Sensor? The Sound Sensor Module provides an easy way to detect sound and is generally used for detecting sound Intensity. This Module can be used Security, Switch and Monitoring applications. Its accuracy can be easily Adjusted for the convenience of the usage. It uses a Microphone which supplies the input to an amplifier, peak detector and buffer. When a Sensor detects a sound , it processes an output signal voltage which is sent to microprocessor , and performs further processing. Material Required: Material Quantity Arduino Uno 1 Sound Sensor 1 Jumper cables 5 Resistor 1(1k ohm) Pinout Diagram: Circuit Diagram: Parameter Value VCC 5 V DC from your Arduino Ground GND from your Arduino Out Connect to Digital Input Pin Tested Programming Code: //Arduino Sound Detection Sensor Module int soundDetectedPin = 10; // Use Pin 10 as our Input int soundDetectedVal = HIGH; // This is where we record our Sound Measurement boolean bAlarm = false; unsigned long lastSoundDetectTime; // Record the time that we measured a sound int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high void setup () { Serial.begin(9600); pinMode (soundDetectedPin, INPUT) ; // input from the Sound Detection Module } void loop () { soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time if (soundDetectedVal == LOW) // If we hear a sound { lastSoundDetectTime = millis(); // record the time of the sound alarm // The following is so you don't scroll on the output screen if (!bAlarm){ Serial.println("LOUD, LOUD"); bAlarm = true; } } else { if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm){ Serial.println("quiet"); bAlarm = false; } } } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of Sound Sensor for correctworking. 5. Don’t lose hope if Sound Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you will want to open your serial monitor. Make some loud noises and and view the results Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of RFID Module with Arduino Uno.

    Back Interfacing of RFID Module with Arduino Uno. What is RFID? Radio-Frequency Identification ( RFID ) is the use of radio waves to read and capture information stored on a tag attached to an object. A tag can be read from up to several feet away and does not need to be within direct line-of-sight of the reader to be tracked. Material Required: Material Quantity Arduino Uno 1 Rfid module 1 Jumper cables 8 Pinout Diagram: Circuit Diagram: Connect the RFID module with Arduino as follows: GND pin of RFID module to GND of Arduino VCC pin of RFID module to 5V of Arduino SDA pin of RFID module to digital pin 10 of Arduino SCK pin of RFID module to digital pin 13 of Arduino. MOSI pin of RFID module to digital pin 11 of Arduino. MISO pin of RFID module to digital pin 12 of Arduino. RST pin of RFID module to digital pin 9 of Arduino. IRQ pin of RFID module is not connected Download RFID Library We need to download the library for RFID. Go to sketch >> include library >> window open >> go to search bar and type <> you see a link >> click on that link and install. Tested Programming Code: #include #include #define RST_PIN 9 #define SS_PIN 10 MFRC522 rfid(SS_PIN, RST_PIN); MFRC522::MIFARE_Key key; void setup() { Serial.begin(9600); SPI.begin(); rfid.PCD_Init(); } void loop() { if( ! rfid.PICC_IsNewCardPresent()||! rfid.PICC_ReadCardSerial()) { return; } MFRC522::PICC_TypepiccType = rfid.PICC_GetType(rfid.uid.sak); String sd = ""; for (byte i = 0; i < 4; i++) { sd += (rfid.uid.uidByte[i] < 0x10 ? "0" : "") + String(rfid.uid.uidByte[i], HEX) + (i!=3 ? ":" : ""); } sd.toUpperCase(); Serial.print("Tap card key: "); Serial.println(sd); rfid.PICC_HaltA (); rfid.PCD_StopCrypto1 (); } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether proper board is selected from Arduino IDE. Ensure proper placement of RFID module Sensor for correct working. Conclusion: Once your sketch is running, you have open serial monitor and then put your RFID tag on RFID module. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of GSM 800 L Modules with Arduino.

    Back Interfacing of GSM 800 L Modules with Arduino. What is a GSM Module ? The SIM800L is a cheap and portable GSM breakout board with all the capabilities of the larger SIM900 shields. In this Arduino SIM800L tutorial, I will help you get started with this nifty device. Sending and receiving texts with your Arduino have never been easier! SIM800L Introduction Here are the features of the SIM800L breakout board: 2G quad-band @ 850/900/1800/1900 MHz Receive and make calls using the speaker and microphone outputs Receive and send SMS Connect to the Internet via GPRS Listen to FM radio broadcasts Accepts AT Commands From the specification of SIM800L we would able to find out that its: Operating Voltage: 3.3 - 5 Volts Recommended voltage: 3.4 - 4.4 Volts Recommended Current: 1 – 2 Amp Therefore, if we use voltages below 3.4, either the SIM800L will not work or it will work but not all its features are responding (e.g unable to read SIM card). But if use voltage equal to its MAXIMUM operating voltage, the module might heat up and then got destroyed, or if we use ABOVE operating voltage, well, it will absolutely destroy the module. Most important, we should not supply a current above 2 Amp (e.g 5 Amp) to the module, it will destroy the module even if your voltage is in 3.4 - 4.4 volts range. But here in our tutorial, you will observe that the module get 5V supply from arduino. That’s sound risky, but as my measurement, computation and observation, 5V pin in Arduino generate current from 500mA -1 Amp which gives a maximum power of 5 Watts. 5 watts qualifies from recommended power which would not cause the module to heat up or destroyed. That’s why 5V pin in Arduino qualifies as a supply voltage. If the power to the SIM800L is enough, the on-board LED starts blinking. The frequency of the blinking means something: Every second: searching for a network. Every three seconds: connected to a network. Twice per second: connected through GPRS. Antennas are essential for this kind of module especially if your project is indoors. Without an antenna, there would not be enough transmitting power for the SIM800L to perform GSM services such as calls and SMS. Material Required: Material Quantity Arduino Uno 1 SIM 800L 1 Jumper cables 6 Breadboard 1 Pinout Diagram: Circuit Diagram: Note: Make sure you already inserted your SIM card before powering the module. If not, you will not see any changes in the module LED indicator. SIM800 VCC ↔ Arduino 5v SIM800 GND ↔ Arduino GND SIM800 SIM_TXD ↔ Arduino pin 3 SIM800 SIM_RXD ↔ Arduino pin 2 Step 2: Code Download and Add Adafriut Fona library to your Arduino library. Then open and upload the Fonatest sample code from Adafruit Fona. Open Serial monitor then change baudrate to 115200 and choose NL & CR. Then you'll see Menu of test setup, choose anything you want to test (e.g send and receive message). Tested Programming Code: #include "Adafruit_FONA.h" #define FONA_RX 2 #define FONA_TX 3 #define FONA_RST 4 // this is a large buffer for replies char replybuffer[255]; // We default to using software serial. If you want to use hardware serial // (because softserial isnt supported) comment out the following three lines // and uncomment the HardwareSerial line #include SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX); SoftwareSerial *fonaSerial = &fonaSS; // Hardware serial is also possible! // HardwareSerial *fonaSerial = &Serial1; // Use this for FONA 800 and 808s Adafruit_FONA fona = Adafruit_FONA(FONA_RST); // Use this one for FONA 3G //Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST); uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0); uint8_t type; void setup() { while (!Serial); Serial.begin(115200); Serial.println(F("FONA basic test")); Serial.println(F("Initializing.. (May take 3 seconds)")); fonaSerial->begin(4800); if (! fona.begin(*fonaSerial)) { Serial.println(F("Couldn't find FONA")); while (1); } type = fona.type(); Serial.println(F("FONA is OK")); Serial.print(F("Found ")); switch (type) { case FONA800L: Serial.println(F("FONA 800L")); break; case FONA800H: Serial.println(F("FONA 800H")); break; case FONA808_V1: Serial.println(F("FONA 808 (v1)")); break; case FONA808_V2: Serial.println(F("FONA 808 (v2)")); break; case FONA3G_A: Serial.println(F("FONA 3G (American)")); break; case FONA3G_E: Serial.println(F("FONA 3G (European)")); break; default: Serial.println(F("???")); break; } // Print module IMEI number. char imei[16] = {0}; // MUST use a 16 character buffer for IMEI! uint8_t imeiLen = fona.getIMEI(imei); if (imeiLen > 0) { Serial.print("Module IMEI: "); Serial.println(imei); } // Optionally configure a GPRS APN, username, and password. // You might need to do this to access your network's GPRS/data // network. Contact your provider for the exact APN, username, // and password values. Username and password are optional and // can be removed, but APN is required. //fona.setGPRSNetworkSettings(F("your APN"), F("your username"), F("your password")); // Optionally configure HTTP gets to follow redirects over SSL. // Default is not to follow SSL redirects, however if you uncomment // the following line then redirects over SSL will be followed. //fona.setHTTPSRedirect(true); printMenu(); } void printMenu(void) { Serial.println(F(" ")); Serial.println(F("[?] Print this menu")); Serial.println(F("[a] read the ADC 2.8V max (FONA800 & 808)")); Serial.println(F("[b] read the Battery V and % charged")); Serial.println(F("[C] read the SIM CCID")); Serial.println(F("[U] Unlock SIM with PIN code")); Serial.println(F("[i] read RSSI")); Serial.println(F("[n] get Network status")); Serial.println(F("[v] set audio Volume")); Serial.println(F("[V] get Volume")); Serial.println(F("[H] set Headphone audio (FONA800 & 808)")); Serial.println(F("[e] set External audio (FONA800 & 808)")); Serial.println(F("[T] play audio Tone")); Serial.println(F("[P] PWM/Buzzer out (FONA800 & 808)")); // FM (SIM800 only!) Serial.println(F("[f] tune FM radio (FONA800)")); Serial.println(F("[F] turn off FM (FONA800)")); Serial.println(F("[m] set FM volume (FONA800)")); Serial.println(F("[M] get FM volume (FONA800)")); Serial.println(F("[q] get FM station signal level (FONA800)")); // Phone Serial.println(F("[c] make phone Call")); Serial.println(F("[A] get call status")); Serial.println(F("[h] Hang up phone")); Serial.println(F("[p] Pick up phone")); // SMS Serial.println(F("[N] Number of SMSs")); Serial.println(F("[r] Read SMS #")); Serial.println(F("[R] Read All SMS")); Serial.println(F("[d] Delete SMS #")); Serial.println(F("[s] Send SMS")); Serial.println(F("[u] Send USSD")); // Time Serial.println(F("[y] Enable network time sync (FONA 800 & 808)")); Serial.println(F("[Y] Enable NTP time sync (GPRS FONA 800 & 808)")); Serial.println(F("[t] Get network time")); // GPRS Serial.println(F("[G] Enable GPRS")); Serial.println(F("[g] Disable GPRS")); Serial.println(F("[l] Query GSMLOC (GPRS)")); Serial.println(F("[w] Read webpage (GPRS)")); Serial.println(F("[W] Post to website (GPRS)")); // GPS if ((type == FONA3G_A) || (type == FONA3G_E) || (type == FONA808_V1) || (type == FONA808_V2)) { Serial.println(F("[O] Turn GPS on (FONA 808 & 3G)")); Serial.println(F("[o] Turn GPS off (FONA 808 & 3G)")); Serial.println(F("[L] Query GPS location (FONA 808 & 3G)")); if (type == FONA808_V1) { Serial.println(F("[x] GPS fix status (FONA808 v1 only)")); } Serial.println(F("[E] Raw NMEA out (FONA808)")); } Serial.println(F("[S] create Serial passthru tunnel")); Serial.println(F(" ")); Serial.println(F("")); } void loop() { Serial.print(F("FONA> ")); while (! Serial.available() ) { if (fona.available()) { Serial.write(fona.read()); } } char command = Serial.read(); Serial.println(command); switch (command) { case '?': { printMenu(); break; } case 'a': { // read the ADC uint16_t adc; if (! fona.getADCVoltage(&adc)) { Serial.println(F("Failed to read ADC")); } else { Serial.print(F("ADC = ")); Serial.print(adc); Serial.println(F(" mV")); } break; } case 'b': { // read the battery voltage and percentage uint16_t vbat; if (! fona.getBattVoltage(&vbat)) { Serial.println(F("Failed to read Batt")); } else { Serial.print(F("VBat = ")); Serial.print(vbat); Serial.println(F(" mV")); } if (! fona.getBattPercent(&vbat)) { Serial.println(F("Failed to read Batt")); } else { Serial.print(F("VPct = ")); Serial.print(vbat);Serial.println(F("%")); } break; } case 'U': { // Unlock the SIM with a PIN code char PIN[5]; flushSerial(); Serial.println(F("Enter 4-digit PIN")); readline(PIN, 3); Serial.println(PIN); Serial.print(F("Unlocking SIM card: ")); if (! fona.unlockSIM(PIN)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; } case 'C': { // read the CCID fona.getSIMCCID(replybuffer); // make sure replybuffer is at least 21 bytes! Serial.print(F("SIM CCID = ")); Serial.println(replybuffer); break; } case 'i': { // read the RSSI uint8_t n = fona.getRSSI(); int8_t r; Serial.print(F("RSSI = ")); Serial.print(n); Serial.print(": "); if (n == 0) r = -115; if (n == 1) r = -111; if (n == 31) r = -52; if ((n >= 2) && (n <= 30)) { r = map(n, 2, 30, -110, -54); } Serial.print(r); Serial.println(F(" dBm")); break; } case 'n': { // read the network/cellular status uint8_t n = fona.getNetworkStatus(); Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": ")); if (n == 0) Serial.println(F("Not registered")); if (n == 1) Serial.println(F("Registered (home)")); if (n == 2) Serial.println(F("Not registered (searching)")); if (n == 3) Serial.println(F("Denied")); if (n == 4) Serial.println(F("Unknown")); if (n == 5) Serial.println(F("Registered roaming")); break; } /*** Audio ***/ case 'v': { // set volume flushSerial(); if ( (type == FONA3G_A) || (type == FONA3G_E) ) { Serial.print(F("Set Vol [0-8] ")); } else { Serial.print(F("Set Vol % [0-100] ")); } uint8_t vol = readnumber(); Serial.println(); if (! fona.setVolume(vol)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; } case 'V': { uint8_t v = fona.getVolume(); Serial.print(v); if ( (type == FONA3G_A) || (type == FONA3G_E) ) { Serial.println(" / 8"); } else { Serial.println("%"); } break; } case 'H': { // Set Headphone output if (! fona.setAudio(FONA_HEADSETAUDIO)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } fona.setMicVolume(FONA_HEADSETAUDIO, 15); break; } case 'e': { // Set External output if (! fona.setAudio(FONA_EXTAUDIO)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } fona.setMicVolume(FONA_EXTAUDIO, 10); break; } case 'T': { // play tone flushSerial(); Serial.print(F("Play tone #")); uint8_t kittone = readnumber(); Serial.println(); // play for 1 second (1000 ms) if (! fona.playToolkitTone(kittone, 1000)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; } case 'f': { // get freq flushSerial(); Serial.print(F("FM Freq (eg 1011 == 101.1 MHz): ")); uint16_t station = readnumber(); Serial.println(); // FM radio ON using headset if (fona.FMradio(true, FONA_HEADSETAUDIO)) { Serial.println(F("Opened")); } if (! fona.tuneFMradio(station)) { Serial.println(F("Failed")); } else { Serial.println(F("Tuned")); } break; } case 'F': { // FM radio off if (! fona.FMradio(false)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; } case 'm': { // Set FM volume. flushSerial(); Serial.print(F("Set FM Vol [0-6]:")); uint8_t vol = readnumber(); Serial.println(); if (!fona.setFMVolume(vol)) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; case 'M': { // Get FM volume. uint8_t fmvol = fona.getFMVolume(); if (fmvol < 0) { Serial.println(F("Failed")); } else { Serial.print(F("FM volume: ")); Serial.println(fmvol, DEC); } break; } case 'q': { // Get FM station signal level (in decibels). flushSerial(); Serial.print(F("FM Freq (eg 1011 == 101.1 MHz): ")); uint16_t station = readnumber(); Serial.println(); int8_t level = fona.getFMSignalLevel(station); if (level < 0) { Serial.println(F("Failed! Make sure FM radio is on (tuned to station).")); } else { Serial.print(F("Signal level (dB): ")); Serial.println(level, DEC); } break; } /*** PWM ***/ case 'P': { // PWM Buzzer output @ 2KHz max flushSerial(); Serial.print(F("PWM Freq, 0 = Off, (1-2000): ")); uint16_t freq = readnumber(); Serial.println(); if (! fona.setPWM(freq)) { break; } /*** Call ***/ case 'c': { // call a phone! char number[30]; flushSerial(); Serial.print(F("Call #")); readline(number, 30); Serial.println(); Serial.print(F("Calling ")); Serial.println(number); if (!fona.callPhone(number)) { Serial.println(F("Failed")); } else { Serial.println(F("Sent!")); } break; } case 'A': { // get call status int8_t callstat = fona.getCallStatus(); switch (callstat) { case 0: Serial.println(F("Ready")); break; case 1: Serial.println(F("Could not get status")); break; case 3: Serial.println(F("Ringing (incoming)")); break; case 4: Serial.println(F("Ringing/in progress (outgoing)")); break; default: Serial.println(F("Unknown")); break; } break; } case 'h': { // hang up! if (! fona.hangUp()) { break; } case 'p': { // pick up! if (! fona.pickUp()) { Serial.println(F("Failed")); } else { Serial.println(F("OK!")); } break; } /*** SMS ***/ case 'N': { // read the number of SMS's! int8_t smsnum = fona.getNumSMS(); if (smsnum < 0) { Serial.println(F("Could not read # SMS")); } else { Serial.print(smsnum); Serial.println(F(" SMS's on SIM card!")); } break; } case 'r': { // read an SMS flushSerial(); Serial.print(F("Read #")); uint8_t smsn = readnumber(); Serial.print(F("\n\rReading SMS #")); Serial.println(smsn); // Retrieve SMS sender address/phone number. if (! fona.getSMSSender(smsn, replybuffer, 250)) { Serial.println("Failed!"); break; } Serial.print(F("FROM: ")); Serial.println(replybuffer); // Retrieve SMS value. uint16_t smslen; if (! fona.readSMS(smsn, replybuffer, 250, &smslen)) { // pass in buffer and max len! Serial.println("Failed!"); break; } Serial.print(F("***** SMS #")); Serial.print(smsn); Serial.print(" ("); Serial.print(smslen); Serial.println(F(") bytes *****")); Serial.println(replybuffer); Serial.println(F("*****")); break; } case 'R': { // read all SMS int8_t smsnum = fona.getNumSMS(); uint16_t smslen; int8_t smsn; if ( (type == FONA3G_A) || (type == FONA3G_E) ) { smsn = 0; // zero indexed smsnum--; } else { smsn = 1; // 1 indexed } for ( ; smsn <= smsnum; smsn++) { Serial.print(F("\n\rReading SMS #")); Serial.println(smsn); if (!fona.readSMS(smsn, replybuffer, 250, &smslen)) { // pass in buffer and max len! Serial.println(F("Failed!")); break; } // if the length is zero, its a special case where the index number is higher // so increase the max we'll look at! if (smslen == 0) { Serial.println(F("[empty slot]")); smsnum++; continue; } Serial.print(F("***** SMS #")); Serial.print(smsn); Serial.print(" ("); Serial.print(smslen); Serial.println(F(") bytes *****")); Serial.println(replybuffer); Serial.println(F("*****")); } break; } case 'd': { // delete an SMS flushSerial(); Serial.print(F("Delete #")); uint8_t smsn = readnumber(); Serial.print(F("\n\rDeleting SMS #")); Serial.println(smsn); if (fona.deleteSMS(smsn)) { Serial.println(F("OK!")); } else { Serial.println(F("Couldn't delete")); } break; } case 's': { // send an SMS! char sendto[21], message[141]; flushSerial(); Serial.print(F("Send to #")); readline(sendto, 20); Serial.println(sendto); Serial.print(F("Type out one-line message (140 char): ")); readline(message, 140); Serial.println(message); if (!fona.sendSMS(sendto, message)) { Serial.println(F("Failed")); } else { Serial.println(F("Sent!")); } break; } case 'u': { // send a USSD! char message[141]; flushSerial(); Serial.print(F("Type out one-line message (140 char): ")); readline(message, 140); Serial.println(message); uint16_t ussdlen; if (!fona.sendUSSD(message, replybuffer, 250, &ussdlen)) { // pass in buffer and max len! Serial.println(F("Failed")); } else { Serial.println(F("Sent!")); Serial.print(F("***** USSD Reply")); Serial.print(" ("); Serial.print(ussdlen); Serial.println(F(") bytes *****")); Serial.println(replybuffer); Serial.println(F("*****")); } } /*** Time ***/ case 'y': { // enable network time sync if (!fona.enableNetworkTimeSync(true)) Serial.println(F("Failed to enable")); break; } case 'Y': { // enable NTP time sync if (!fona.enableNTPTimeSync(true, F("pool.ntp.org"))) Serial.println(F("Failed to enable")); break; } case 't': { // read the time char buffer[23]; fona.getTime(buffer, 23); // make sure replybuffer is at least 23 bytes! Serial.print(F("Time = ")); Serial.println(buffer); break; } /*********************************** GPS (SIM808 only) */ case 'o': { // turn GPS off if (!fona.enableGPS(false)) Serial.println(F("Failed to turn off")); break; } case 'O': { // turn GPS on if (!fona.enableGPS(true)) Serial.println(F("Failed to turn on")); break; } case 'x': { int8_t stat; // check GPS fix stat = fona.GPSstatus(); if (stat < 0) Serial.println(F("Failed to query")); if (stat == 0) Serial.println(F("GPS off")); if (stat == 1) Serial.println(F("No fix")); if (stat == 2) Serial.println(F("2D fix")); if (stat == 3) Serial.println(F("3D fix")); break; } case 'L': { // check for GPS location char gpsdata[120]; fona.getGPS(0, gpsdata, 120); if (type == FONA808_V1) Serial.println(F("Reply in format: mode,longitude,latitude,altitude,utctime(yyyymmddHHMMSS),ttff,satellites,speed,course")); else Serial.println(F("Reply in format: mode,fixstatus,utctime(yyyymmddHHMMSS),latitude,longitude,altitude,speed,course,fixmode,reserved1,HDOP, PDOP,VDOP,reserved2,view_satellites,used_satellites,reserved3,C/N0max,HPA,VPA")); Serial.println(gpsdata); break; } case 'E': { flushSerial(); if (type == FONA808_V1) { Serial.print(F("GPS NMEA output sentences (0 = off, 34 = RMC+GGA, 255 = all)")); } else { Serial.print(F("On (1) or Off (0)? ")); } uint8_t nmeaout = readnumber(); // turn on NMEA output fona.enableGPSNMEA(nmeaout); break; } /*********************************** GPRS */ case 'g': { // turn GPRS off if (!fona.enableGPRS(false)) Serial.println(F("Failed to turn off")); break; } case 'G': { // turn GPRS on if (!fona.enableGPRS(true)) Serial.println(F("Failed to turn on")); break; } case 'l': { // check for GSMLOC (requires GPRS) uint16_t returncode; if (!fona.getGSMLoc(&returncode, replybuffer, 250)) Serial.println(F("Failed!")); if (returncode == 0) { Serial.println(replybuffer); } else { Serial.print(F("Fail code #")); Serial.println(returncode); } break; } case 'w': { // read website URL uint16_t statuscode; int16_t length; char url[80]; flushSerial(); Serial.println(F("NOTE: in beta! Use small webpages to read!")); Serial.println(F("URL to read (e.g. www.adafruit.com/testwifi/index.html):") ); Serial.print(F("http://")); readline(url, 79); Serial.println(url); Serial.println(F("****")); if (!fona.HTTP_GET_start(url, &statuscode, (uint16_t *)&length)){ Serial.println("Failed!"); break; } while (length > 0) { while (fona.available()) { char c = fona.read(); // Serial.write is too slow, we'll write directly to Serial register! #if defined(AVR_ATmega328P ) || defined( AVR_ATmega168) loop_until_bit_is_set(UCSR0A, UDRE0); /* Wait until data register empty. */ UDR0 = c; #else #endif } Serial.write(c); length--; if (! length) break; } Serial.println(F("\n****")); fona.HTTP_GET_end(); break; } case 'W': { // Post data to website uint16_t statuscode; int16_t length; char url[80]; char data[80]; flushSerial(); Serial.println(F("NOTE: in beta! Use simple websites to post!")); Serial.println(F("URL to post (e.g. httpbin.org/post):")); Serial.print(F("http://")); readline(url, 79); Serial.println(url); Serial.println(F("Data to post (e.g. \"foo\" or \"{\"simple\":\"json\"}\"):")); readline(data, 79); Serial.println(data); Serial.println(F("****")); if (!fona.HTTP_POST_start(url, F("text/plain"), (uint8_t *) data, strlen(data), &statuscode, (uint16_t *)&length)) { Serial.println("Failed!"); break; } while (length > 0) { while (fona.available()) { char c = fona.read(); #if defined( AVR_ATmega328P ) || defined( AVR_ATmega168 ) loop_until_bit_is_set(UCSR0A, UDRE0); /* Wait until data register empty. */ UDR0 = c; #else #endif Serial.write(c); length--; if (! length) break; } } Serial.println(F("\n****")); fona.HTTP_POST_end(); break; } /*****************************************/ case 'S': { Serial.println(F("Creating SERIAL TUBE")); while (1) { while (Serial.available()) { delay(1); fona.write(Serial.read()); } if (fona.available()) { Serial.write(fona.read()); } } break; } default: { Serial.println(F("Unknown command")); printMenu(); break; } } // flush input flushSerial(); while (fona.available()) { Serial.write(fona.read()); } } void flushSerial() { while (Serial.available()) Serial.read(); } char readBlocking() { while (!Serial.available()); return Serial.read(); } uint16_t readnumber() { uint16_t x = 0; char c; while (! isdigit(c = readBlocking())) { //Serial.print(c); } Serial.print(c); x = c - '0'; while (isdigit(c = readBlocking())) { Serial.print(c); x *= 10; x += c - '0'; } return x; } uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout) { uint16_t buffidx = 0; boolean timeoutvalid = true; if (timeout == 0) timeoutvalid = false; while (true) { if (buffidx > maxbuff) { //Serial.println(F("SPACE")); break; } while (Serial.available()) { char c = Serial.read(); //Serial.print(c, HEX); Serial.print("#"); Serial.println(c); if (c == '\r') continue; if (c == 0xA) { if (buffidx == 0) // the first 0x0A is ignored continue; timeout = 0; // the second 0x0A is the end of the line timeoutvalid = true; break; } buff[buffidx] = c; buffidx++; } if (timeoutvalid && timeout == 0) { //Serial.println(F("TIMEOUT")); break; } delay(1); } buff[buffidx] = 0; // null term return buffidx; } Precautions: 1. Double check the connections before powering on thecircuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from ArduinoIDE. 4. Ensure proper placement of sensor for correct working. 5. Don’t lose hope if Flex Sensor or LED does not runs properly for the first time, try again. Conclusion: You can successfully interface different devices using the Resistance principle of Flex Sensor.s Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing with MQ-3 Alcohol Sensor Module

    Back Interfacing with MQ-3 Alcohol Sensor Module MQ-3 gas sensor has high sensitivity to alcohol, and has good resistance to disturbances of gasoline, smoke and vapor. The sensor could be used to detect alcohol with different concentration; it is with low cost and suitable for different application. Sensitive material of MQ-3 gas sensor is SnO2, which with lower conductivity in clean air. When the target alcohol gas exists, sensor’s conductivity is proportional to the gas concentration. Description: 1. Model No: MQ-3. 2. Heater voltage: 5±0.2V. 3. Loop voltage: ≤24V (DC) 4. Load resistance: Adjustable. 5. Heating Resistance: 31Ω±3Ω (Room temperature). 6. Heating Power: ≤ 900mW. 7. Surface thermal resistance: 2Kohm-20Kohm (0.4mg/L alcohol). 8. Sensitivity: Rs (in air)/Rs (0.4mg/L alcohol) ≥ 5. Application Example with Arduino Uno: Connect the MQ-3 alcohol sensor module to Arduino Uno board as shown below: Programming Code /* MQ-3 Alcohol Sensor Circuit with Arduino */ const int AOUTpin=A0; //the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino const int DOUTpin=8; //the DOUT pin of the alcohol sensor goes into digital pin D8 of the arduino const int ledPin=13; //the anode of the LED connects to digital pin D13 of the arduino int limit; int value; void setup() { Serial.begin(115200); pinMode(DOUTpin, INPUT); pinMode(ledPin, OUTPUT); } void loop() { value= analogRead(AOUTpin); //reads the analaog value from the alcohol sensor's AOUT pin limit= digitalRead(DOUTpin); //reads the digital value from the alcohol sensor's DOUT pin Serial.print(" Alcohol value: "); Serial.println(value); //prints the alcohol value Serial.print("Limit: "); Serial.print(limit); //prints the limit reached as either LOW or HIGH (above or underneath) delay(100); if (limit == HIGH) { digitalWrite(ledPin, HIGH);//if limit has been reached, LED turns on as status indicator } else{ digitalWrite(ledPin, LOW); //if threshold not reached, LED remains off } } Result: Open up the Serial Monitor with Baud rate of 115200, the alcohol level detected will be shown as analog value. The alcohol limit value can be set with sensitivity potentiometer: if the alcohol level detected is below the set limit, the D0 green indicator will be off. If detected alcohol level is beyond the set limit, the DO LED will light up. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of Touch Sensor with Arduino Uno.

    Back Interfacing of Touch Sensor with Arduino Uno. What is a Touch Sensor? This device uses your body as part of the circuit. When you touch the sensor pad, the capacitance of the circuit is changed and is detected. That detected change in capacitance results in the output changing states. Material Required: Material Quantity Arduino Uno 1 Touch Sensor 1 Jumper cables 4 Pinout Diagram: Pin of Touch sensor: 1. GND. 2. VCC. 3. SIG Circuit Diagram: Connect the Touch Sensor with Arduino as follows: GND pin of Touch sensor to GND of Arduino VCC pin of Touch Sensor to 5V of Arduino SIG pin of Touch Sensor to digital pin 2 of Arduino. Tested Programming Code: #define ctsPin 2 int ledPin = 13; // pin for the LED void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(ctsPin, INPUT); } void loop() { int ctsValue = digitalRead(ctsPin); if (ctsValue==HIGH) { digitalWrite(ledPin, HIGH); Serial.println("TOUCHED"); } else{ digitalWrite(ledPin,LOW); Serial.println("not touched"); } delay(500); } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether proper board is selected from Arduino IDE. Ensure proper placement of Touch Sensor for correct working. Conclusion: Once your sketch is running, you have to see the Touch Sensor working by seeing the Serial monitor whenever it is being touched. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • 4*4 Keypad Interfacing with Arduino UNO.

    Back 4*4 Keypad Interfacing with Arduino UNO. What is a 4*4 Keypad? In embedded devices one of the essential parts is Keypad is used to interact with embedded devices, Keypad is an input device that is used to give the command to the devices, from the calculator to the computer input is given through the keypad. 4×4 Matrix Keypad and how the Arduino Keypad Interface works. A Keypad is an input device that is used to enter passwords, dial a number, browse through the menu and even control robots. Material Required: Material Quantity Arduino Uno 1 4*4 Keypad 1 Jumper cables 8 Pinout Diagram: If you have a keypad look for one below. The below diagram is enough for knowing pin configuration. Circuit Diagram: Follow the given pin order for wiring the circuit. As shown in the left diagram. Start from left to right. Keypad Pin 1 (R4) –> Arduino Pin 2 Keypad Pin 2 (R3) –> Arduino Pin 3 Keypad Pin 3 (R2) –> Arduino Pin 4 Keypad Pin 5 (C4) –> Arduino Pin 6 Keypad Pin 6 (C3) –> Arduino Pin 7 Keypad Pin 7 (C2) –> Arduino Pin 8 Keypad Pin 8 (C1) –> Arduino Pin 9 Tested Programming Code: /* ##### 4x4 Membrane Keypad Arduino Interfacing #####Arduino and Keypad Connection Keypad Pin => Arduino Pin 1 => Digital Pin 2 2 => Digital Pin 3 3 => Digital Pin 4 4 => Digital Pin 5 5 => Digital Pin 6 6 => Digital Pin 7 7 => Digital Pin 8 8 => Digital Pin 9* #include const byte ROWS = 4; //four rows const byte COLS = 4; //four columns // Define the Keymap char hexaKeys[ROWS][COLS] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the Rows of the keypad pin 8, 7, 6, 5 respectively byte colPins[COLS] = {5, 4, 3, 2}; //connect to the Columns of the keypad pin 4, 3, 2, 1 respectively //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); void setup (){ Serial.begin(9600); } void loop (){ char customKey = customKeypad.getKey(); if (customKey){ Serial.println(customKey); // Send the pressed key value to the arduino serial monitor } } Checking Values on Serial Monitor: After successfully uploading the Program to the Arduino Board, You can check the input given through the keypad on the Serial monitor. Precautions: 1. Double-check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Connect the Wiper pin of the potentiometer correctly. 6. Don’t lose hope if Keypad does not run properly for the first time, try again Conclusion: You can successfully display inputs given in the keypad on the Serial Monitor in the simplest way using Arduino. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno

    Back Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno What is a Matrix Display? Dot-matrix LED display contains the group of LEDs as a two-dimensional array. They can display different types of characters or a group of characters. Dot-matrix LED display contains the group of LEDs as a two-dimensional array. They can display different types of characters or a group of characters. Dot-matrix display is manufactured in various dimensions. The arrangement of LEDs in the matrix pattern is made in either of the two ways: Row anode-column cathode or Row cathode-column anode. By using this dot matrix display we can reduce the number of pins required for controlling all the LEDs. Material Required: Material Quantity Arduino Uno 1 MAX 7219 Display Module 1 Jumper cables 5 Pinout Diagram: Circuit Diagram: Working: An LED dot matrix consists of an array of LEDs that are connected such that the anode of each LED is connected in the same column and the cathode of each LED is connected in the same row or vice versa . Here each dot represents circular lenses in front of LEDs. This is done to minimize the number of pins required to drive them. For example, an 8X8 matrix of LEDs would need 64 I/O pins, one for each LED pixel. By connecting all the anodes of LEDs in a column and all the cathodes together in a row, the required number of input and output pins is reduced to 16. Each LED will be addressed by its row and column number. Controlling the LED Matrix: Since all the LEDs in a matrix share their positive and negative terminals in each row and column, it is not possible controlling of each LED at the same time. The matrix controlled through each row very quickly by triggering the correct column pins to light the desired LED for that particular row. If the switching is done with a fixed rate, humans can’t see the displaying message, because the human eye can’t detect the images within the milliseconds. Thus the displaying of a message on an LED matrix must be controlled, with the rows being scanned sequentially at a rate greater than 40 MHz while sending out the column data at the same rate. This kind of control can be done by interfacing the LED matrix display with the microcontroller. Interfacing the LED Matrix Display with Microcontroller: Choosing a microcontroller for interfacing with the LED matrix display which is to be controlled is depends on the number of input and output pins needed for controlling all the LEDs in the given matrix display, the amount of current that each pin can source and sink, and the speed at which the microcontroller can send out control signals. With all these specifications, interfacing can be done for LED matrix display with a microcontroller. Tested Programming Code: A library needs to be downloaded and then to be installed. Go to Disk drive where your Arduino IDE is installed and then go to > Program Files>Arduino> Libraries> then Ctrl+V (Paste). https://github.com/riyas-org/max7219/tree/master/MaxMatrix https://github.com/riyas-org/max7219 : Main Link #include int DIN = 7; // DIN pin of MAX7219 module int CLK = 6; // CLK pin of MAX7219 module int CS = 5; // CS pin of MAX7219 module int maxInUse = 1; MaxMatrix m(DIN, CS, CLK, maxInUse); char A[] = {4, 8, B01111110, B00010001, B00010001, B01111110, }; char B[] = {4, 8, B01111111, B01001001, B01001001, B00110110, }; char smile01[] = {8, 8, B00111100, B01000010, B10010101, B10100001, B10100001, B10010101, B01000010, B00111100 }; char smile02[] = {8, 8, B00111100, B01000010, B10010101, B10010001, B10010001, B10010101, B01000010, B00111100 }; char smile03[] = {8, 8, B00111100, B01000010, B10100101, B10010001, B10010001, B10100101, B01000010, B00111100 }; void setup() { m.init(); // MAX7219 initialization m.setIntensity(8); // initial led matrix intensity, 0-15 } void loop() { // Seting the LEDs On or Off at x,y or row,column position m.setDot(6,2,true); delay(1000); m.setDot(6,3,true); delay(1000); m.clear(); // Clears the display for (int i=0; i<8; i++){ m.setDot(i,i,true); delay(300); } m.clear(); // Displaying the character at x,y (upper left corner of the character) m.writeSprite(2, 0, A); delay(1000); m.writeSprite(2, 0, B); delay(1000); m.writeSprite(0, 0, smile01); delay(1000); m.writeSprite(0, 0, smile02); delay(1000); m.writeSprite(0, 0, smile03); delay(1000); for (int i=0; i<8; i++){ m.shiftLeft(false,false); delay(300); } m.clear(); } Program Description: So first we need to include the MaxMatrix.h library, define the pins to which the module is connected, set how many modules we use and define the MaxMatrix object. For displaying characters, we need to define them in an array of characters or bytes, and here I have several examples. We can notice how the bits are forming the characters which are zeros and ones. In this case, they are rotated 90 degrees but the library example suggests using them in such a way so that would be easier later to implement the shift left custom function for scrolling a text. Precautions: 1. Double Check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check Whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. Conclusion: You can successfully program different characters on a matrix display, this display can be combined with many more displays to get a larger display area. Output:: Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of Laser Diode with Arduino Uno.

    Back Interfacing of Laser Diode with Arduino Uno. What is a Laser Diode? A laser diode , ( LD ), injection laser diode ( ILD ), or diode laser is a semiconductor device similar to a light-emitting diode in which the laser beam is created at the diode's junction.[1] Laser diodes are the most common type of lasers produced, with a wide range of uses that include fiber optic communications, barcode readers, laser pointers, CD/DVD/Blu-ray disc reading/recording, laser printing, laser scanning and light beam illumination. Material Required: Material Quantity Arduino Uno 1 Laser Diode 1 Jumper cables 2 Pinout Diagram: Circuit Diagram: Connect the Laser Diode with Arduino as follows: GND pin of Laser diode to GND of Arduino Signal pin of laser diode to digital pin 8 of Arduino Tested Programming Code: //we define the laser diode on digital pin 8 of Arduino. Int laser = 8 Void setup () { // we define the laser as output. pinMode (laser, OUTPUT); } Void loop () { //here we keep laser ON for half a seconds. digitalWrite (laser, HIGH); //wait for half a seconds . delay (500); // here we keep laser OFF for half a second. digitalWrite (laser, LOW); //wait for half a seconds. delay (500); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of laser diode for correct working. 5. Never look directly into a laser, it will cause eye damage. Conclusion: Once your sketch is running, you have to see the red spot on wall. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Measuring water flow rate and calculating quantity using Flow Sensor with Arduino.

    Back Measuring water flow rate and calculating quantity using Flow Sensor with Arduino. What is a Water Flow Sensor? The water flow sensor consists of a plastic valve body, a water rotor, and a hall-effect sensor. When water flows through the rotor, the rotor rolls. Its speed changes with different rates of flow. The hall-effect sensor outputs the corresponding pulse signal. This one is suitable to detect flow in a water dispenser or coffee machine. Specifications · Mini. Working Voltage: DC 4.5V · Max. Working Current: 15mA (DC 5V) · Working Voltage: DC 5V · Flow Rate Range: 1~30L/min · Operating Temperature: 80 C · Liquid Temperature: 120 · Operating Humidity: 35%~90%RH · Water Pressure: 1.75MPa Material Required: Material Quantity Arduino Uno 1 Water Flow Sensor 1 Jumper cables 3 Pinout Diagram: Working: This illustration gives a detailed working method of the Hall effect sensor-based water flow sensor, a turbine wheel embedded with a magnet is placed on a closed plastic envelope and a Hall effect sensor is placed, When the water flows through the pipeline, it makes the turbine wheel to rotate and hence the magnet flux interferes the hall sensor, the rate of interference depends on the speed of water flow, so the hall effect sensor produces pulse signal output, this pulse output can be calculated as water volume. Circuit Diagram: Connect the +5V wire to Arduino power pin 5V and Ground pin to Gnd then connect the Signal pin to Digital pin D2, this sensor has a control circuit hence there is no need for pull up resistor, some sensor requires to pull up resistors refer to the datasheet of water flow sensor before concluding hookup. Tested Programming Code: The code uses an external interrupt on the Arduino's digital pin 2. This is used to read the pulses coming from the flow meter. When the Arduino detects the pulse, it immediately triggers the pulseCounter() function. This function then counts the total number of pulses. In this Arduino flow rate sensor, for every liter of liquid passing through it per minute, it outputs about 4.5 pulses. Dividing the total pulse count by 4.5 will give you the total amount of liquid passing through it in liters per minute. Dividing that by 60 will give you the flow rate in liters per hour, which gives us the total amount or quantity of water/liquid that has passed through it. The sensor is accurate to within 3%. Code: byte statusLed = 13; byte sensorInterrupt = 0; byte sensorPin = 2; float calibrationFactor = 4.5; volatile byte pulseCount; float flowRate; unsigned int flowMilliLitres; unsigned long totalMilliLitres; unsigned long oldTime; void setup() { Serial.begin(38400); pinMode(statusLed, OUTPUT); digitalWrite(statusLed, HIGH); pinMode(sensorPin, INPUT); digitalWrite(sensorPin, HIGH); pulseCount = 0; flowRate = 0.0; flowMilliLitres = 0; totalMilliLitres = 0; oldTime = 0; attachInterrupt(sensorInterrupt, pulseCounter, FALLING); } void loop() { if((millis() - oldTime) > 1000) // Only process counters once per second { detachInterrupt(sensorInterrupt); flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor; oldTime = millis(); flowMilliLitres = (flowRate / 60) * 1000; totalMilliLitres += flowMilliLitres; unsigned int frac; Serial.print("Flow rate: "); Serial.print(int(flowRate)); Serial.print("."); frac = (flowRate - int(flowRate)) * 10; Serial.print(frac, DEC) ; Serial.print("L/min"); Serial.print(" Current Liquid Flowing: "); Serial.print(flowMilliLitres); Serial.print("mL/Sec"); Serial.print(" Output Liquid Quantity: "); Serial.print(totalMilliLitres); Serial.println("mL"); pulseCount = 0; attachInterrupt(sensorInterrupt, pulseCounter, FALLING); } } void pulseCounter() { pulseCount++; } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether the proper board is selected from Arduino IDE. Ensure proper placement of sensor for correct working. Please keep your hardware away from water except, the water flow sensor. Conclusion: You can successfully measure the flow rate and quantity of the water flowing through a pipe through a cross-sectional area. This sensor can be deployed in many ways like water level automation systems, water meters, etc. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Displaying a text message on LCD Display using 16X2 Segment Display with Arduino.

    Back Displaying a text message on LCD Display using 16X2 Segment Display with Arduino. What is a LCD Display ? A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device that uses the light-modulating properties of liquid crystals. LCDs are available to display arbitrary images or fixed images with low information content, which can be displayed or hidden, such as preset words, digits. Material Required: Material Quantity Arduino Uno 1 16X2 Segment Display 1 Jumper cables 20 10 k Potentiometer 1 Pinout Diagram: It has 16 pins and the first one from left to right is the Ground pin. The second pin is the VCC which we connect the 5 volts pin on the Arduino Board. Next is the Vo pin on which we can attach a potentiometer for controlling the contrastof the display. Next, The RS pin or register select pin is used for selecting whether we will send commands or data to the LCD. For example if the RS pin is set on low state or zero volts, then we are sending commands to the LCD like: set the cursor to a specific location, clear the display, turn off the display and so on. And when RS pin is set on High state or 5 volts we are sendingdata or characters to the LCD. After all we don’t have to worry much about how the LCD works, as the Liquid Crystal Library takes care for almost everything. From the Arduino’s official website you can find and see the functions of the library which enable easy use of the LCD. We can use the Library in 4 or 8 bit mode. In this tutorial we will use it in 4 bit mode, or we will just use 4 of the 8 data pins. Circuit Diagram: We will use just 6 digital input pins from the Arduino Board. The LCD’s registers from D4 to D7 will be connected to Arduino’s digital pins from 4 to 7. The Enable pin will be connected to pin number 2 and the RS pin will be connected to pin number 1. The R/W pin will be connected to Ground and the Vo pin will be connected to the potentiometer. Tested Programming Code: First thing we need to do is it insert the Liquid Crystal Library. We can do that like this: Sketch > Include Library > Liquid Crystal. Then we have to create an LC object. The parameters of this object should be the numbers of the Digital Input pins of the Arduino Board respectively to the LCD’s pins as follow: (RS, Enable, D4, D5, D6, D7). In the setup we have to initialize the interface to the LCD and specify the dimensions of the display using thebegin() function. In the loop we write our main program. Using the print() function we print on the LCD. The setCursor()function is used for setting the location at which subsequent text written to the LCD will be displayed. The blink() function is used for displaying a blinking cursor and the noBlink() function for turning off. The cursor() function is used for displaying underscore cursor and the noCursor() function for turning off. Using the clear() function we can clear the LCD screen. // include the library code: #include // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis() / 1000); Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Connect the Wiper pin of potentiometer correctly. 6. Don’t lose hope if LCD does not runs properly for the first time, try again. Conclusion: You can successfully measure display data on a LCD in simplest way using Arduino. Many forms of data can be displayed on this display, whether it can be a data from sensor or a anything else . Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Motion Detection using PIR Sensor with Arduino

    Back Motion Detection using PIR Sensor with Arduino What is a PIR sensor? PIR sensors allow you to sense motion. They are used to detect whether a human has moved in or out of the sensor’s range. They are commonly found in appliances and gadgets used at home or for businesses. They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors. Following are the advantages of PIR Sensors − · Small in size · Wide lens range · Easy to interface· · Inexpensive · Low-power · Easy to use · Do not wear out Material Required: Material Quantity Arduino Uno 1 PIR Motion Sensor 1 Jumper cables 3 Pinout Diagram: Circuit Diagram: Working: The module actually consists of a Pyroelectric sensor which generates energy when exposed to heat. That means when a human or animal body will get in the range of the sensor it will detect a movement because the human or animal body emits heat energy in a form of infrared radiation. That’s where the name of the sensor comes from, a Passive Infra-Red sensor. And the term “passive” means that sensor is not using any energy for detecting purposes, it just works by detecting the energy given off by the other objects. The module also consists a specially designed cover named Fresnel lens, which focuses the infrared signals onto the pyroelectric sensor. You can adjust the sensor sensitivity and delay time via two variable resistors located at the bottom of the sensor board. Tested Programming Code: /* * PIR sensor tester */ int ledPin = 13; // choose the pin for the LED int inputPin = 2; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val= 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON if (pirState == LOW) { // we have just turned on Serial.println("Motion detected!"); // We only want to print on the output change, not state pirState = HIGH; } } else { digitalWrite(ledPin, LOW); // turn LED OFF if (pirState == HIGH) { // we have just turned of Serial.println("Motion ended!"); // We only want to print on the output change, not state pirState = LOW; } } } Precautions: 1. Double Check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check Whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Don’t come in range of the sensor, else it will be always triggering ON. Conclusion: You can successfully check for Motion Detection using an IR sensor. Many more other applications can be made using PIR Motion sensor as it has many possibilities to work with. Output: Once the sensor detects any motion, Arduino will send a message via the serial port to say that a motion is detected. The PIR sense motion will delay for certain time to check if there is a new motion. If there is no motion detected, Arduino will send a new message saying that the motion has ended. Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Measuring Distance using Ultrasonic Sensor with Arduino

    Back Measuring Distance using Ultrasonic Sensor with Arduino What is an Ultrasonic Sensor? An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object. Since it is known that sound travels through air at about 344 m/s (1129 ft/s), you can take the time for the sound wave to return and multiply it by 344 meters (or 1129 feet) to find the total round-trip distance of the sound wave. Round-trip means that the sound wave traveled 2 times the distance to the object before it was detected by the sensor; it includes the 'trip' from the sonar sensor to the object AND the 'trip' from the object to the Ultrasonic sensor (after the sound wave bounced off the object). To find the distance to the object, simply divide the round-trip distance in half. Pinout diagram: Material Required: Material Quantity Arduino Uno 1 Ultrasonic Sensor 1 Jumper cables 4 Circuit Diagram: Working: It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. In order to generate the ultrasound, you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound waves traveled. For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound waves needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2. Tested Programming Code: // defines pins numbers const int trigPin = 9; const int echoPin = 10; // defines variables long duration; int distance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); } Precautions: 1. Double Check the connections before powering on thecircuit. 2. Don’t use loose jumper cables. 3. Check Whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. Conclusion: You can Measure distance using this ultrasonic sensor, without use of any measuring tape or high priced instrument. Many more other applications can be made using ultrasonic sensor as it has many possibilities to work with. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing GPS with Arduino (Neo-6M-001)

    Back Interfacing GPS with Arduino (Neo-6M-001) What is a GPS Module? Every single location in the entire globe can be specified in terms of geographical coordinates. The geographical coordinate is a system which specifies any given location on the earth surface as latitude and longitude. There are devices which can read the geographical coordinates of a place with the help of the signals received from a number of satellites orbiting the earth. The system of satellites which helps in the positioning of a place is called Global Positioning System (GPS). The devices which can read the geographical coordinates of a place with the help of at least four GPS satellites are called GPS Receiver or simply GPS module. Specifications: • Build in 18X18mm GPS antenna • Anti-jamming technology • 5Hz position update rate • Operating temperature range: -40 TO 85°C • UART TTL socket • EEprom to store settings Material Required: Material Quantity Arduino Uno 1 GPS Module 1 Jumper cables 4 Working: GPS satellites circle the Earth twice a day in a precise orbit. Each satellite transmits a unique signal and orbital parameters that allow GPS devices to decode and compute the precise location of the satellite. GPS receivers use this information and trilateration to calculate a user's exact location. Essentially, the GPS receiver measures the distance to each satellite by the amount of time it takes to receive a transmitted signal. With distance measurements from a few more satellites, the receiver can determine a user's position and display it. To calculate your 2-D position (latitude and longitude) and track movement, a GPS receiver must be locked on to the signal of at least 3 satellites. With 4 or more satellites in view, the receiver can determine your 3-D position (latitude, longitude and altitude). Generally, a GPS receiver will track 8 or more satellites, but that depends on the time of day and where you are on the earth. Once your position has been determined, the GPS unit can calculate other information, such as: Speed Bearing Track Trip dist istance to destination Download and install required libraries for GPS to work in Arduino IDE (i) SoftwareSerial library (ii) TinyGPS library Click on the highlighted link to download the Library. Circuit Diagram: Connection of Arduino UNO and GPS module : Connect the four pins from UBLOX to an Arduino as follows: Ublox - Arduino GND - GND TX - Digital pin (D3) RX - Digital pin (D4) Vcc - 5Vdc Here, I suggest you to use external power supply to power the GPS module because minimum power requirement for GPS module to work is 3.3 V and Arduino is not capable of providing that much voltage. Tested Programming Code: #include #include SoftwareSerial mySerial(3,4); TinyGPS gps; void gpsdump(TinyGPS &gps); void printFloat(double f, int digits = 2); void setup() { // Oploen serial communications and wait for port to open: Serial.begin(9600); // set the data rate for the SoftwareSerial port mySerial.begin(9600); delay(1000); Serial.println("uBlox Neo 6M"); Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.println("by Mikal Hart"); Serial.println(); Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS)); Serial.println(); } void loop() // run over and over { bool newdata = false; unsigned long start = millis(); // Every 5 seconds we print an update while (millis() - start < 5000) { if (mySerial.available()) { char c = mySerial.read(); //Serial.print(c); // uncomment to see raw GPS data if (gps.encode(c)) { newdata = true; break; // uncomment to print new data immediately! } } } if (newdata) { Serial.println("Acquired Data"); Serial.println("-------------"); gpsdump(gps); Serial.println("-------------"); Serial.println(); } } void gpsdump(TinyGPS &gps) { long lat, lon; float flat, flon; unsigned long age, date, time, chars; int year; byte month, day, hour, minute, second, hundredths; unsigned short sentences, failed; gps.get_position(&lat, &lon, &age); Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); // On Arduino, GPS characters may be lost during lengthy Serial.print() // On Teensy, Serial prints to USB, which has large output buffering and // runs very fast, so it's not necessary to worry about missing 4800 // baud GPS characters. gps.f_get_position(&flat, &flon, &age); Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5); Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); gps.get_datetime(&date, &time, &age); Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): "); Serial.print(time); Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); Serial.print("Date: "); Serial.print(static_cast(month)); Serial.print("/"); Serial.print(static_cast(day)); Serial.print("/"); Serial.print(year); Serial.print(" Time: "); Serial.print(static_cast(hour+8)); Serial.print(":"); //Serial.print("UTC +08:00 Malaysia"); Serial.print(static_cast(minute)); Serial.print(":"); Serial.print(static_cast(second)); Serial.print("."); Serial.print(static_cast(hundredths)); Serial.print(" UTC +08:00 Malaysia"); Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): "); Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed()); Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): "); printFloat(gps.f_course()); Serial.println(); Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): "); printFloat(gps.f_speed_mph()); Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): "); printFloat(gps.f_speed_kmph()); Serial.println(); gps.stats(&chars, &sentences, &failed); Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed); } void printFloat(double number, int digits) { // Handle negative numbers if (number < 0.0) { Serial.print('-'); number = -number; } // Round correctly so that print(1.999, 2) prints as "2.00" double rounding = 0.5; for (uint8_t i=0; i 0) Serial.print("."); // Extract digits from the remainder one at a time while (digits-- > 0) { remainder *= 10.0; int toPrint = int(remainder); Serial.print(toPrint); remainder -= toPrint; }} Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working.. Conclusion: You can successfully measure the flow rate and quantity of the water flowing through a pipe through a cross sectional area. This sensor can be deployed in many ways like water level automation system, water meter etc. Output: After you have successfully uploaded your source code, open your serial monitor. Serial monitor will display the data that your gps required. If you didn’t get anything, make sure your connection is correct and try it outside or near the window where it is easy to get the signal. Signal may not reach inside a building. Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of 28BYJ Stepper Driver with Arduino.

    Back Interfacing of 28BYJ Stepper Driver with Arduino. What is so special about steppers? A stepper motor can move in accurate, fixed angle increments known as steps. For practical purposes, a stepper motor is a bit like a servo: you can tell it to move to a pre-defined position and can count on getting fairly consistent results with multiple repetitions. Servos though, are usually limited to a 0-180 degree range, while a stepper motor can rotate continuously, similar to a regular DC motor. The advantage of steppers over DC motors is that you can achieve much higher precision and control over the movement. The downside of using steppers is that they are a bit more complex to control than servos and DC motors . The 28BYJ-48 Stepper Motor Datasheet The 28BYJ-48 is a small, cheap, 5 volt geared stepping motors. These stepping motors are apparently widely used to control things like automated blinds, A/C units and are mass produced. Due to the gear reduction ratio of *approximately* 64:1 it offers decent torque for its size at speeds of about 15 rotations per minute (RPM). With some software “trickery” to accelerate gradually and a higher voltage power source (I tested them with 12 volts DC) I was able to get about 25+ RPM. These little steppers can be purchased together with a small breakout board for the Arduino compatible ULN2003 stepper motor driver for less than $5. Quite a bargain, compared to the price of a geared DC motor, a DC motor controller and a wheel encoder! The low cost and small size makes the 28BYJ-48 an ideal option for small robotic applications, and an excellent introduction to stepper motor control with Arduino. Here are the detailed specs of the 28BYJ-48 stepper motor. Motor Type Unipolar stepper motor Connection Type 5 Wire Connection (to the motor controller) Voltage 5-12 Volts DC Frequency 100 Hz Step mode Half-step mode recommended(8 step control signal sequence) Half-step mode: 8 step control signal sequence (recommended) 5.625 degrees per step / 64 steps per one revolution of the internal motor shaft Full Step mode: 4 step control signal Step angle sequence 11.25 degrees per step / 32 steps per one revolution of the internal motor shaft Manufacturer specifies 64:1 . Some patient and diligent people on the Arduino forums have disassembled the gear train of these little motors and determined that the exact gear ratio is in fact 63.68395:1 . My observations confirm their findings. These means that in the recommended half-step mode we will have:64 steps per motor rotation x 63.684 gear ratio = Gear ratio 4076 steps per full revolution (approximately). Wiring to the ULN2003 controller A (Blue), B (Pink), C (Yellow), D (Orange), E (Red, Mid- Point) Weight 30g Material Required: Material Quantity Arduino Uno 1 Stepper Driver 1 Jumper cables 6 Stepper Motor 1 Pinout Diagram: The motor has 4 coils of wire that are powered in a sequence to make the magnetic motor shaft spin. When using the full-step method, 2 of the 4 coils are powered at each step. The default stepper library that comes pre-installed with the Arduino IDE uses this method. The 28BYH-48 datasheet specifies that the preferred method for driving this stepper is using the half-step method, where we first power coil 1 only, then coil 1 and 2 together, then coil 2 only and so on…With 4 coils, this means 8 different signals, like in the table below. Circuit Diagram: Wiring the ULN2003 stepper motor driver to Arduino Uno : The ULN2003 stepper motor driver board allows you to easily control the 28BYJ-48 stepper motor from a microcontroller, like the Arduino Uno. One side of the board side has a 5 wire socket where the cable from the stepper motor hooks up and 4 LEDs to indicate which coil is currently powered. The motor cable only goes in one way, which always helps. On the side you have a motor on / off jumper (keep it on to enable power to the stepper). The two pins below the 4 resistors, is where you provide power to the stepper. Note that powering the stepper from the 5 V rail of the Arduino is not recommended. A separate 5-12 V 1 Amp power supply or battery pack should be used, as the motor may drain more current than the microcontroller can handle and could potentially damage it. In the middle of the board we have the ULN2003 chip. At the bottom are the 4 control inputs that should be connected to four Arduino digital pins . Hooking it up to the Arduino Connect the ULN2003 driver IN1, IN2, IN3 and IN4 to digital pin 3, 4, 5 and 6 respectively on the Arduino Uno. Connect the positive lead from a decent 5-12V battery pack to the “+” pin of the ULN2003 driver and the ground to the “-” pin. Make sure that the “on/off” jumper next to the “-” pin is on. If you power the Arduino from a different battery pack, connect the grounds together. Arduino stepper code and the AccelStepper library The default stepper library that comes pre-installed with the Arduino IDE supports the full-step method only and has limited features. It does not run the 28BYJ-48 motors very efficiently and getting two of them running at the same time for a differential drive robot is a bit more difficult. I came across example sketch by 4tronix that used the half-step method with no additional libraries. Their code worked well and I was able to modify it, so that I can run two steppers at the same time. Still, I was only able to get my stepper motor spinning fairly slow and it was getting quite warm, for some reason. Additionally, that sample code uses delays for the steps and that will cause some issues when we start adding more complex functions in the loop and hook up various sensors. Then I came across the AccelStepper library. It runs the 28BYJ-48 steppers very efficiently (they never go as hot as with the other options I tried) and also supports acceleration (which allows the stepper to get to a higher speed). The library uses non blocking code for the steps and has quite a few other nice features. After some messing around with the documentation and the examples I got everything up and running. Below is the code that will slowly accelerate the 28BYJ-48 in one direction, then decelerate to a stop and accelerate in the opposite direction. Naturally, make sure you download and install the AccelStepper library first! #include #define HALFSTEP 8 // Motor pin definitions #define motorPin1 3 // IN1 on the ULN2003 driver 1 #define motorPin2 4 // IN2 on the ULN2003 driver 1 #define motorPin3 5 // IN3 on the ULN2003 driver 1 #define motorPin4 6 // IN4 on the ULN2003 driver 1 // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48 AccelStepper stepper1 ( HALFSTEP , motorPin1 , motorPin3 , motorPin2 , motorPin4 ); void setup () { stepper1 . setMaxSpeed ( 1000.0 ); stepper1 . setAcceleration ( 100.0 ); stepper1 . setSpeed ( 200 ); stepper1 . moveTo ( 20000 ); } //--(end setup )--- void loop () { //Change direction when the stepper reaches the target position if ( stepper1 . distanceToGo () == 0 ) { stepper1 . moveTo (- stepper1 . currentPosition ()); } stepper1 . run (); } The code above will not push this motor to its limit. You can experiment with the acceleration and speed settings to see what is the best you can squeeze out. Note that for nigher speeds, you will likely need a higher voltage DC source. If you got your stepper running, here is the code that the StepperBot from the video above is running. You will need to adjust the speed, as well variables based on your base and wheel sizes, if you want to have your bot moving in a square path. #include #define HALFSTEP 8 // motor pins #define motorPin1 3 // IN1 on the ULN2003 driver 1 #define motorPin2 4 // IN2 on the ULN2003 driver 1 #define motorPin3 5 // IN3 on the ULN2003 driver 1 #define motorPin4 6 // IN4 on the ULN2003 driver 1 #define motorPin5 8 // IN1 on the ULN2003 driver 2 #define motorPin6 9 // IN2 on the ULN2003 driver 2 #define motorPin7 10 // IN3 on the ULN2003 driver 2 #define motorPin8 11 // IN4 on the ULN2003 driver 2 // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48 AccelStepper stepper1 ( HALFSTEP , motorPin1 , motorPin3 , motorPin2 , motorPin4 ); AccelStepper stepper2 ( HALFSTEP , motorPin5 , motorPin7 , motorPin6 , motorPin8 ); // variables int turnSteps = 2100 ; // number of steps for a 90 degree turn int lineSteps = - 6600 ; //number of steps to drive straight int stepperSpeed = 1000 ; //speed of the stepper (steps per second) int steps1 = 0 ; // keep track of the step count for motor 1 int steps2 = 0 ; // keep track of the step count for motor 2 boolean turn1 = false ; //keep track if we are turning or going straight next boolean turn2 = false ; //keep track if we are turning or going straight next void setup () { delay ( 3000 ); //sime time to put the robot down after swithing it on stepper1 . setMaxSpeed ( 2000.0 ); stepper1 . move ( 1 ); // I found this necessary stepper1 . setSpeed ( stepperSpeed ); stepper2 . setMaxSpeed ( 2000.0 ); stepper2 . move (- 1 ); // I found this necessary stepper2 . setSpeed ( stepperSpeed ); } void loop () { if ( steps1 == 0 ) { int target = 0 ; if ( turn1 == true ) { target = turnSteps ; } else { target = lineSteps ; } stepper1 . move ( target ); stepper1 . setSpeed ( stepperSpeed ); turn1 = ! turn1 ; } if ( steps2 == 0 ) { int target = 0 ; if ( turn2 == true ) { target = turnSteps ; } else { target = - lineSteps ; } stepper2 . move ( target ); stepper2 . setSpeed ( stepperSpeed ); turn2 = ! turn2 ; } steps1 = stepper1 . distanceToGo (); steps2 = stepper2 . distanceToGo (); stepper1 . runSpeedToPosition (); stepper2 . runSpeedToPosition (); } Tested Programming Code: #define IN1 3 #define IN2 4 #define IN3 5 #define IN4 6 int Steps = 4096; //4096 or 768 int cstep = 0; void setup() { Serial.begin(9600); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); } void loop() { for(int x=0;x

  • Measuring Humidity and temperature using DHT11 sensor with Arduino.

    Back Measuring Humidity and temperature using DHT11 sensor with Arduino. What is a Digital Humidity Temperature Sensor? DHT11 is a Humidity and Temperature Sensor, which generates calibrated digital output. DHT11 can be interface with any microcontroller like Arduino, Raspberry Pi, etc. and get instantaneous results. DHT11 is a low-cost humidity and temperature sensor which provides high reliability and long-term stability. Material Required: Material Quantity Arduino Uno 1 DHT11 Sensor 1 Jumper cables 3 Pinout Diagram: Working: Ok now let’s see how these sensors work. They consist of a humidity sensing component, an NTC temperature sensor (or thermistor) and an IC on the back side of the sensor. For measuring humidity they use the humidity sensing component which has two electrodes with moisture holding substrate between them. So as the humidity changes, the conductivity of the substrate changes or the resistance between these electrodes changes. This change in resistance is measured and processed by the IC which makes it ready to be read by a microcontroller. On the other hand, for measuring temperature these sensors use an NTC temperature sensor or a thermistor. A thermistor is a variable resistor that changes its resistance with the temperature change. These sensors are made by sintering semiconductive materials such as ceramics or polymers to provide larger changes in the resistance with just small temperature changes. The term “NTC” means “Negative Temperature Coefficient”, which means that the resistance decreases with an increase in the temperature. Circuit Diagram: The DHTxx sensors have four pins, VCC, GND, data pin and a not connected pin which has no usage. A pull-up resistor from 5K to 10K Ohms is required to keep the data line high and to enable the communication between the sensor and the Arduino Board. There are some versions of these sensors that come with a breakout board with a built-in pull-up resistor and they have just 3 pins. The DHTXX sensors have their single wire protocol used for transferring the data. This protocol requires precise timing and the timing diagrams for getting the data from the sensors can be found in the datasheets of the sensors. However, we don’t have to worry much about these timing diagrams because we will use the DHT library which takes care of everything. Tested Programming Code: First, we need to include the DHT library which can be found from the Arduino official website or can be downloaded from the following link https://github.com/adidax/dht11 then define the PIN to which our sensor is connected and create a DHT object. In the setup section, we need to initiate the serial communication because we will use the serial monitor to print the results. Using the read22() function we will read the data from the sensor and put the values of the temperature and the humidity into the t and h variables. If you use the DHT11 sensor you will need to you the read11() function. In the end, we will print the temperature and the humidity values on the serial monitor. #include "DHT.h" #define DHTPIN 2 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin(); } void loop() { measurements. delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); float f =dht.readTemperature(true); if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } float hi = dht.computeHeatIndex(f, h); Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hi); Serial.println(" *F"); } After we will upload this code to the Arduino board, the temperature and humidity results from the sensor can be seen on the Serial monitor. Precautions: Double-check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether the proper board is selected from Arduino IDE. Ensure proper placement of sensor for correct working. Don’t put the sensor in any fluid or water, this is meant for taking ambient readings only. Conclusion: You can successfully measure temperature and humidity using the DHT11 sensor. Many more other applications can be made and triggered using the DHT11 sensor. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of Metal Touch Sensor with Arduino.

    Back Interfacing of Metal Touch Sensor with Arduino. What is a Metal Touch Sensor? A metal touch sensor is a type of switch that only operates when it's touched by a charged body. It has a high-frequency transistor which can conduct electricity when receiving electromagnetic signals. The sensor has 3 main components on its circuit board. First, the sensor unit at the front of the module which measures the area physically and sends an analog signal to the second unit, the amplifier. The amplifier amplifies the signal, according to the resistant value of the potentiometer, and sends the signal to the analog output of the module. The third component is a comparator which switches the digital out and the LED if the signal falls under a specific value. In this experiment, touch the base electrode of a transistor with fingers to make it conduct electricity, for human body itself is a kind of conductor and an antenna that can receive electromagnetic waves in the air. These electromagnetic wave signals collected by human body are amplified by the transistor and processed by the comparator on the module to output steady signals. You can control the sensitivity by adjusting the potentiometer. Please notice: The signal will be inverted; that means that if you measure a high value, it is shown as a low voltage value at the analog output. Technical data / Short description Outputs a signal if the metal pike of the Sensor was touched. You can adjust the sensitivity of the sensor with the controller. Digital Out: At the moment of contact detection, a signal will be outputted. Analog Out: Direct measuring value of the sensor unit. LED1: Shows that the sensor is supplied with voltage LED2: Shows that the sensor detects a magnetic field Material Required: Material Quantity Arduino Uno 1 Metal Touch Sensor 1 Jumper cables 4 Pinout Diagram: This sensor doesn't show absolute values (like exact temperature in °C or magnetic field strength in mT). It is a relative measurement: you define an extreme value to a given normal environment situation and a signal will be send if the measurement exceeds the extreme value. Tested Programming Code: // Declaration and initialization of the input pin int Analog_Eingang = A0; int Digital_Eingang = 3; void setup () { pinMode (Analog_Eingang, INPUT); pinMode (Digital_Eingang, INPUT); Serial.begin (9600); } // The program reads the current value of the input pins // and outputs it via serial out void loop () { float Analog; int Digital; // Current value will be read and converted to the voltage Analog = analogRead (Analog_Eingang) * (5.0 / 1023.0); Digital = digitalRead (Digital_Eingang); // and outputted here Serial.print ("Analog voltage value:"); Serial.print (Analog, 4); Serial.print ("V, "); Serial.print ("Extreme value:"); if(Digital==1) { Serial.println (" reached"); } Else { Serial.println (" not reached yet"); } Serial.println ("----------------------------------------------------------------"); delay (200); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Don’t lose hope if Sensor does not run properly for the first time, try again. Conclusion: You can successfully interface metal touch sensor and check for different conductivity values and can use it to detect different bodies when they come in contact. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

  • Interfacing of Temperature Sensor (LM35) with Arduino Uno.

    Back Interfacing of Temperature Sensor (LM35) with Arduino Uno. What is a Temperature Sensor? LM35 is a precision temperature sensor with its output proportional to the temperature (in C). With LM35, temperature can be measured more accurately than with a thermistor. It also possess low self heating and does not cause more than 0.1 C temperature rise in still air. The operating temperature range is from -55°C to 150°C. The output voltage varies by 10mV in response to ambient temperature; its scale factor is 0.01V/ C. Material Required: Material Quantity Arduino Uno 1 Temperature Sensor(LM35) 1 Jumper cables 4 Pinout Diagram: Circuit Diagram: Parameter Value VCC 5 V DC from your Arduino Ground GND from your Arduino Out Connect to Analog Pin A0 Tested Programming Code: float tempC; int reading; int tempPin = 0; void setup() { analogReference(INTERNAL); Serial.begin(9600); } void loop() { reading = analogRead(tempPin); tempC = reading / 9.31; Serial.print("Temprature= "); Serial.print(tempC); Serial.print("*C"); Serial.println(); delay(1000); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of Temperature Sensor for correct working. 5. Don’t lose hope if Temperature Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor. There you can see the Temperature of the surroundings. Reference URL GET IN TOUCH We'd love to hear from you Contact Us

bottom of page