إظهار الرسائل ذات التسميات ARDUINO. إظهار كافة الرسائل
إظهار الرسائل ذات التسميات ARDUINO. إظهار كافة الرسائل
الثلاثاء، 19 يناير 2016
الثلاثاء، 8 ديسمبر 2015
Multiple Shift-out Registers on Arduino – part 2
4:48 م
mourad
In this second article we will see a practical application of the daisy-chained shift registers.
We want to use four 7-Segments LEDs controlled by the Arduino board.
As you can imagine, that is impossible without a series of
shift-registers as we need 32 output pins. As we can do in many other
applications of the daisy-chained shift registers, in this case we don’t
need a specific software or library: it is sufficient what we already
know about the shift registers.
As in the previous article I wrote that the board is a general purpose tool, this is one of the hundreds possible applications that only need hardware. The only thing we must know is how the 7-segments LED devices work.
The 7-segments LED devices
The general principle behind this kind of devices is the same that makes the common LEDs working. To get a LED lighting we should connect its ground pin to the circuit GND and the positive pin to an output pin on the microcontroller. Everytime the microcontroller pin goes high the LED is powered.
It’s important to know that there are two different types of 7-segments LED displays: common cathode and common anode. As shown in the scheme below the common cathode display shares the GND signal while the common anode display shares the VCC signal.
By the point of view of the circuit schematics there are no particular differences and we have adopted common anode devices because of some advantages compared to the opposite common cathode.
The only different thing is our sketch; We should consider that with this kind of configuration a certain LED segment will light when the corresponding digital pin of the shift register is set to LOW and vice-versa.
As the 7-segments display components have eight independent LEDs (seven for the bars and one extra for the point), every segment corresponds to one of the 8 signals/pins of the corresponding shift register so the four display board consumes four shift registers.
Why the choice of the Common Anode Display
The board has a set of connectors showing 33 pins: four sets of eight pins plus the common pin connected to the anodes of the four devices. This 33th pin can be connected to the shift register board – explained in the previous article – that shares the VCC signal on its connectors: simply connect one-to-one the two boards and it will work.
But what happens when you connect the VCC common anode of the board to one of the free digital pins of the Arduino? Setting the common anode digital pin to HIGH, we power on the entire display board while setting it to LOW the display board will not work. One more suggestion: if we use an Arduino PWM pin as the common anode pin, we can power on/off the display and change its brightness.
What if using Common Cathode Display
If we put in the sockets four 7-segments LED common cathode LCD display devices, we should connect the pin 33 of the board (the common pin) to the Arduino GND signal. At this point, all works fine again, the only difference being that every display LED segment is enabled when the corresponding shift register signal is ON and is disabled when the signal is OFF.
7-segments Display mapping
As every segment is associated to one of the corresponding bits (with an extra eight bit for the separator point) there are 128 different statuses of the devices. With the board and the daisy-chained shift register we can set any of these configurations but the most common are the characters 0-9 and A-F. For more information on how the 7-segments LED displays work, read this almost exhaustive description on wikipedia.
Sketches suggestions and samples
What now? There are many helpful suggestions to manage the board in your Arduino sketches. The ideal hardware configuration will be the four daisy-chained shift registers described in the first part of this article and the 7-segments board discussed above.
Don’t forget to try using an Arduino digital pin instead of the VCC pin to control the common anode signal of the LEDs.
- #include <ShiftOutX.h>
- #include <ShiftPinNo.h>
-
- // Digital pins connected to 74HC595
- int latchPin = 2; // pin 12 on the 74hc595
- int dataPin = 3; // pin 14 on the 74hc595
- int clockPin = 4; // pin 11 on the 74hc595
-
- // Digital pin to enable/disable the display common Anode
- int vccControlPin = 7;
-
- //shiftOutX(_latchPin, _dataPin, _clockPin, _bitOrder, _NofRegisters);
- shiftOutX shiftDisplay(latchPin, dataPin, clockPin, MSBFIRST, 4);
-
- void setup() {
-
- // Set the ShiftRegister PINs
- pinMode(latchPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
-
- // Set the common Anode control pin
- pinMode(vccControlPin, OUTPUT);
-
- // Disable (power off) the display disabling the common Anode pin
- digitalWrite(vccControlPin, LOW);
-
- // Initialize the serial (for testing purposes)
- Serial.begin(9600);
-
- // Startup message
- Serial.println("/*** Display 7 Segments Test Started ***/");
-
- }
-
- void loop() {
-
- // Enable the display
- digitalWrite(vccControlPin, HIGH);
- Serial.println("- Display on");
- delay(2000); // wait 2 sec
-
- shiftDisplay.allOn();
- Serial.println("- shiftDisplay.allOn()");
- delay(2000); // wait 2 sec
-
- shiftDisplay.allOff();
- Serial.println("- shiftDisplay.allOff()");
- delay(2000); // wait 2 sec
-
- // Disable (power off) the display disabling the common Anode pin
- digitalWrite(vccControlPin, LOW);
- Serial.println("- Display Off");
- delay(2000); // wait 2 sec
- }
You can find a pre-assembled daisy-chained four shift registers board or the PCB only at BalearicDynamics. Don’t forget to use the discount code ELEKTRO1008 to get 20% off discount, the special price for Electroschematics.com users.
الأحد، 6 ديسمبر 2015
Arduino Linear Thermistor Experiment
11:48 ص
mourad
Thermistor is a semiconductor device made of materials whose
resistance varies as a function of temperature. A thermistor can be used
to compensate for temperature variation in other components of an
electronic circuit.
Here is an Arduino experiment with a famed linear active thermistor chip MCP9700A from Microchip Technology Inc. The chip comprises an analog temperature sensor that converts temperature to analog voltage. Unlike resistive sensors, this linear active thermistor chip does not require an additional signal- conditioning circuit. Therefore, the biasing circuit development overhead for thermistor solutions can be nullified by implementing this low-cost IC. Further, the voltage output (VOUT) pin can be directly connected to the ADC input of a microcontroller.
Although the 3-pin SOT-23 package of MCP9700A is very popular, the experiment was conducted with an MCP9700A in 5-pin SC70 package, purchased from an online store (RhydoLabz). The chip soldered on the SC70 – DIP adapter was linked to an Arduino UNO (R3) as shown below.
Next important hardware is a standard 16×2 LCD unit. The experiment was conducted with an Arduino compatible LCD shield, circuit diagram of the relevant section is shown below.
The shield consists of a 1602 white character blue backlight LCD, and a keypad consists of 5 keys (select, up, down, right, and left). To save the digital I/O pins, the keypad interface uses only one ADC channel (A0) for reading the key values through a 5-stage resistive-voltage divider.

Now it is clear, a MCP9700A temperature sensor connected to the Arduino analog input pin A1 is used to measure temperature. The Arduino sketch for the experiment handles the inputted data and displays the current temperature on the display panel. That’s all!

Here is an Arduino experiment with a famed linear active thermistor chip MCP9700A from Microchip Technology Inc. The chip comprises an analog temperature sensor that converts temperature to analog voltage. Unlike resistive sensors, this linear active thermistor chip does not require an additional signal- conditioning circuit. Therefore, the biasing circuit development overhead for thermistor solutions can be nullified by implementing this low-cost IC. Further, the voltage output (VOUT) pin can be directly connected to the ADC input of a microcontroller.
Although the 3-pin SOT-23 package of MCP9700A is very popular, the experiment was conducted with an MCP9700A in 5-pin SC70 package, purchased from an online store (RhydoLabz). The chip soldered on the SC70 – DIP adapter was linked to an Arduino UNO (R3) as shown below.
Next important hardware is a standard 16×2 LCD unit. The experiment was conducted with an Arduino compatible LCD shield, circuit diagram of the relevant section is shown below.
The shield consists of a 1602 white character blue backlight LCD, and a keypad consists of 5 keys (select, up, down, right, and left). To save the digital I/O pins, the keypad interface uses only one ADC channel (A0) for reading the key values through a 5-stage resistive-voltage divider.
Now it is clear, a MCP9700A temperature sensor connected to the Arduino analog input pin A1 is used to measure temperature. The Arduino sketch for the experiment handles the inputted data and displays the current temperature on the display panel. That’s all!
/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
Project: Arduino Temperature Monitor
Description: Realized using the simple MCP9700A linear thermistor
connected to pin A1 of the Arduino Uno (R3). The system converts
the output voltage from MCP9700A to a temperature value
and displays it on a 16x2 LCD
Tested at: TechNode PROTOLABZ
Date: November 2015
Author: T.K.Hareendran (with great respect for the inspirations of other designers/coders)
Exclusive for: http://www.electroschematics.com
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
#include <LiquidCrystal.h>
// Arduino pins used for LCD
LiquidCrystal lcd(8, 9,4, 5, 6, 7);
void setup() {
// initialize the LCD display
lcd.begin(16, 2);
}
void loop() {
float temperature = 0.0; // stores the calculated reading
int sample; // counts through ADC samples
float ten_samples = 0.0; // stores sum of 10 samples
// take 10 samples from the MCP9700 sensor
for (sample = 0; sample < 10; sample++) {
// convert A1 value to temperature
temperature = ((float)analogRead(A1) * 5.0 / 1024.0) ‐ 0.5; // 500mV offset corrected – see datasheet of MCP9700
temperature = temperature / 0.01;
// sample every 10ms
delay(100);
// sum of all samples
ten_samples = ten_samples + temperature;
}
// get the average value of 10 samples
temperature = ten_samples / 10.0;
// display the temperature on the LCD
lcd.setCursor(0, 0);
lcd.print(temperature);
lcd.print(" deg. C ");
ten_samples = 0.0;
}
Notes- Overall stability of the system can be increased by adding two 100nF capacitors very close to the MCP9700A chip as indicated in the following diagram. This stabilises the power input, and the signal output from MCP9700A
- The 6 μA (typical) low operating current of the MCP9700A makes it ideal for battery-powered applications. However, for applications that require a tighter current budget, this device can be powered from one Input/ Output (I/O) pin of the Arduino microcontroller. The I/O pin can be toggled to shut down the device

