2016/08/15
Part List Of MakerDolly 1200mm Camera Slider Mechanical Kit
Labels:
Camera,
Dolly,
Kit,
List,
MakerDolly,
Mechanical,
Part,
Slider
2016/07/31
Adafruit Max6675 Library For Thermocouple Need To Be Modified To Run On ESP8266
Test the sketch "Wiring Thermocouple Max6675 on ESP8266 12E NodeMCU" of 14Core, and find Adafruit MAX6675 library installed using Library Manager is not compatible with ESP8266.
By replacing max6675.h and max6675.cpp with the ones from SirUli on github, copying other files on the link and commenting out the statements relating display functions, the sketch of 14Core has been compiled and run without fail on NodeMCU Dev Kit 1.0.
Also the serialthermocoupl.pde example sketch runs without fail.
I think the tutorials of 14Core had better specify from where the library they downloaded.
Wiring from 14Core
Output
Sketch
#include <max6675.h>
// #include <Wire.h>
// #include <Adafruit_GFX.h>
// #include <ESP_Adafruit_SSD1306.h>
// #define OLED_RESET 4
int ktcSO = 12;
int ktcCS = 13;
int ktcCLK = 14;
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
// Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Serial.begin(115200);
Serial.println("Max6675 test");
delay(500);
// display.begin(SSD1306_SWITCHCAPVCC, 0x78>>1);
// display.display();
// delay(2000);
// display.clearDisplay();
}
void loop() {
// basic readout test
//
// display.setTextSize(2);
// display.setTextColor(WHITE);
// display.setCursor(52,10);
// display.print((char)223);
// display.print("C = ");
// display.print(ktc.readCelsius());
// display.print((char)223);
// display.print("\t F = ");
// display.setCursor(52,30);
// display.println(ktc.readFahrenheit());
float DC = ktc.readCelsius();
// Read temperature as Celsius
float DF = ktc.readFahrenheit();
Serial.print("C = ");
Serial.print(ktc.readCelsius());
Serial.print("\t F = ");
Serial.println(ktc.readFahrenheit());
//
delay(1000);
// displayData();
}
void displayData(){
// display.setTextSize(1);
// display.setCursor(5,1);
// display.println("14CORE|THERMOCOUPLE");
// display.setTextSize(2);
// display.setTextColor(WHITE);
// display.setCursor(18,20);
// display.print((char)248);
// display.print("C:");
// display.print(ktc.readCelsius());
// display.setCursor(18,40);
// display.print((char)248);
// display.print("F:");
// display.println(ktc.readFahrenheit());
// display.display();
// display.clearDisplay();
}
By replacing max6675.h and max6675.cpp with the ones from SirUli on github, copying other files on the link and commenting out the statements relating display functions, the sketch of 14Core has been compiled and run without fail on NodeMCU Dev Kit 1.0.
Also the serialthermocoupl.pde example sketch runs without fail.
I think the tutorials of 14Core had better specify from where the library they downloaded.
Wiring from 14Core
Output
Sketch
#include <max6675.h>
// #include <Wire.h>
// #include <Adafruit_GFX.h>
// #include <ESP_Adafruit_SSD1306.h>
// #define OLED_RESET 4
int ktcSO = 12;
int ktcCS = 13;
int ktcCLK = 14;
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
// Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Serial.begin(115200);
Serial.println("Max6675 test");
delay(500);
// display.begin(SSD1306_SWITCHCAPVCC, 0x78>>1);
// display.display();
// delay(2000);
// display.clearDisplay();
}
void loop() {
// basic readout test
//
// display.setTextSize(2);
// display.setTextColor(WHITE);
// display.setCursor(52,10);
// display.print((char)223);
// display.print("C = ");
// display.print(ktc.readCelsius());
// display.print((char)223);
// display.print("\t F = ");
// display.setCursor(52,30);
// display.println(ktc.readFahrenheit());
float DC = ktc.readCelsius();
// Read temperature as Celsius
float DF = ktc.readFahrenheit();
Serial.print("C = ");
Serial.print(ktc.readCelsius());
Serial.print("\t F = ");
Serial.println(ktc.readFahrenheit());
//
delay(1000);
// displayData();
}
void displayData(){
// display.setTextSize(1);
// display.setCursor(5,1);
// display.println("14CORE|THERMOCOUPLE");
// display.setTextSize(2);
// display.setTextColor(WHITE);
// display.setCursor(18,20);
// display.print((char)248);
// display.print("C:");
// display.print(ktc.readCelsius());
// display.setCursor(18,40);
// display.print((char)248);
// display.print("F:");
// display.println(ktc.readFahrenheit());
// display.display();
// display.clearDisplay();
}
IPs And Domain Names of NTP Servers Available Publicly In Taiwan
From time to time I need an NTP server available publicly in Taiwan for reference to compare with my homebrew MakerNTP (posted on Dec. 24, 2015) Stratum 1 GPS-based NTP server, so I list some useful NTP servers.
1. time.stdtime.gov.tw: 118.163.81.61
2. tick.stdtime.gov.tw: 118.163.81.62
3. watch.stdtime.gov.tw: 118.163.81.63
4. tock.stdtime.gov.tw: 211.22.103.157
5. clock.stdtime.gov.tw: 211.22.103.158
6. tw.pool.ntp.org: A. 103.18.128.60 B. 117.56.223.235 C. 59.124.29.241 D. 59.125.122.217
1. time.stdtime.gov.tw: 118.163.81.61
2. tick.stdtime.gov.tw: 118.163.81.62
3. watch.stdtime.gov.tw: 118.163.81.63
4. tock.stdtime.gov.tw: 211.22.103.157
5. clock.stdtime.gov.tw: 211.22.103.158
6. tw.pool.ntp.org: A. 103.18.128.60 B. 117.56.223.235 C. 59.124.29.241 D. 59.125.122.217
2016/07/13
Sketch Displaying Temperature and Humidity on Serial Monitor Using ESP8266 NodeMCU Dev Kit 1.0 and DHT11
Output
Sketch
// Modified by Befun Hung on Jul. 13, 2016 with Arduino IDE supporting ESP8266
// Runs on NodeMCU Dev Kit 1.0 without fails with DHT11 breakout
// Original source code from 14core.com commented out OLED part and correct typos
// "Wiring DHT11, DHT22, with OLED Screen on ESP8266 12E"
// Wiring diagram show data pin of DHT connect D6 (GPIO 12)
// While the sketch define DHTPIN 14 (D5)
// #include <Wire.h>
// #include <Adafruit_GFX.h>
// #include <ESP_Adafruit_SSD1306.h>
#include "ESP8266WiFi.h"
#include "DHT.h"
// #define OLED_RESET 4
// Adafruit_SSD1306 display(OLED_RESET);
// #define DHTPIN 12 // Connected to Pin D6 in NodeMCU
#define DHTPIN 14 // Connected to Pin D5 in NodeMCU
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
/*
byte img [] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0,
0x0, 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0xfc,
0x3f, 0x80, 0x0, 0x0, 0x3, 0xe0, 0x7, 0xc0, 0x0, 0x0, 0x7, 0x80, 0x1, 0xe0, 0x0,
0x0, 0xff, 0x0, 0x0, 0xff, 0x0, 0x3, 0xfe, 0x0, 0x0, 0x7f, 0xc0, 0x7, 0xe2, 0x0,
0x0, 0x4f, 0xe0, 0x7, 0x80, 0x0, 0x0, 0x1, 0xe0, 0xf, 0x0, 0x0, 0x0, 0x0, 0xf0,
0x1e, 0x0, 0x0, 0x0, 0x0, 0x70, 0xe, 0x0, 0x0, 0x0, 0x0, 0x78, 0xc, 0x0, 0x0,
0x0, 0x0, 0x30, 0xc, 0x0, 0x0, 0x0, 0x0, 0x30, 0xc, 0x0, 0x0, 0x0, 0x0, 0x30,
0xe, 0x0, 0x0, 0x0, 0x0, 0x70, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x70, 0xf, 0x0, 0x0,
0x0, 0x0, 0xf0, 0x7, 0x80, 0x0, 0x0, 0x1, 0xe0, 0x7, 0xe3, 0x80, 0x1, 0xc7, 0xe0,
0x3, 0xff, 0xc0, 0x3, 0xff, 0xc0, 0x0, 0xff, 0xf0, 0xf, 0xff, 0x0, 0x0, 0x20, 0xfc,
0x3f, 0x4, 0x0, 0x0, 0x0, 0x3f, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf0, 0x0, 0x0,
0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0x0,
0x0, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x0, 0x0, 0x0, 0x0,
0x0, 0x1f, 0x0, 0x0, 0x20, 0x0, 0x0, 0x1f, 0x0, 0x0, 0x20, 0x0, 0x0, 0xe, 0x0,
0x0, 0x70, 0x0, 0x0, 0x0, 0x1, 0x80, 0x70, 0x0, 0x0, 0x0, 0x1, 0x80, 0xf8, 0x0,
0x0, 0x0, 0x3, 0xc0, 0xf8, 0x0, 0x0, 0x0, 0x3, 0xc0, 0xf8, 0x0, 0x0, 0x0, 0x3,
0xc0, 0x70, 0x0, 0x0, 0x0, 0x3, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xc0, 0x0, 0x0,
0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
*/
void setup() {
Serial.begin(115200);
Serial.println("DHTxx test!");
// dht begin
dht.begin();
// set display
// display.begin(SSD1306_SWITCHCAPVCC, 0x78>>1);
// display.display();
// delay(2000);
// display.clearDisplay();
}
/*
void showTemp(float temp,float hud) {
display.drawBitmap(0, 5, img, 48, 50, 1);
display.setTextSize(1);
display.setCursor(3,0);
display.println("Temperature/Humidity");
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(52,10);
display.print(temp);
display.println("C");
display.setCursor(52,30);
display.print(hud);
display.println("%");
display.setTextSize(1);
display.setCursor(52,50);
display.println("14CORE.COM");
display.display();
display.clearDisplay();
}
*/
void loop() {
delay(2000); // Wait a few seconds between measurements.
float h = dht.readHumidity();
// Serial.print("h= ");
// Serial.println(h);
float t = dht.readTemperature(); // Read temperature as Celsius
// Serial.print("t= ");
// Serial.println(t);
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
Serial.println();
return;
}
Serial.print("Humidity: "); // show in serial monitor
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: "); // show in serial monitor
Serial.print(t);
Serial.print(" *C \n");
// showTemp(t,h); // show temp
}
2016/06/22
Install MQTT Broker Mosquitto on Raspberry Pi
I have installed the MQTT Broker Mosquitto on my Raspberry Pi Model B+ with Raspbian Jessie pre-installed following the procedure described below a few days ago. The version of Mosquitto installed is 1.4.9 supporting both MQTT protocol 3.1 and 3.1.1.
It is stated on module page of NodeMCU documentation website ( https://nodemcu.readthedocs.io/en/master/en/modules/mqtt/ )that:
"The client adheres to version 3.1.1 of the MQTT protocol. Make sure that your broker supports and is correctly configured for version 3.1.1. The client is backwards incompatible with brokers running MQTT 3.1."
1. Update your packages:
sudo apt-get update
sudo apt-get upgrade
2. To use the new repository, import the repository package signing key:
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
sudo rm mosquitto-repo.gpg.key
3. Make the repository available to apt:
cd /etc/apt/sources.list.d/
4. Install the packages list for your version of Raspbian.
For Wheezy (old version)
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
For Jessie (latest version)
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
5. Update apt information and install Mosquitto:
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
It is stated on module page of NodeMCU documentation website ( https://nodemcu.readthedocs.io/en/master/en/modules/mqtt/ )that:
"The client adheres to version 3.1.1 of the MQTT protocol. Make sure that your broker supports and is correctly configured for version 3.1.1. The client is backwards incompatible with brokers running MQTT 3.1."
1. Update your packages:
sudo apt-get update
sudo apt-get upgrade
2. To use the new repository, import the repository package signing key:
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
sudo rm mosquitto-repo.gpg.key
3. Make the repository available to apt:
cd /etc/apt/sources.list.d/
4. Install the packages list for your version of Raspbian.
For Wheezy (old version)
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
For Jessie (latest version)
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
5. Update apt information and install Mosquitto:
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
Additional Board Manager URLs For Arduino IDE
Here's my collection of additional board manager URLs for Arduino IDE version 1.6.4 or greater - don't use 1.6.2!
ESP8266
http://arduino.esp8266.com/stable/package_esp8266com_index.json
MediaTek LinkIt Smart 7688 DUO
http://download.labs.mediatek.com/package_mtk_linkit_smart_7688_test_index.json
MediaTek LinkIt One
http://download.labs.mediatek.com/package_mtk_linkitone_index.json
Realtek Ameba
https://github.com/Ameba8195/Arduino/raw/master/release/package_realtek.com_ameba_index.json
2016/05/09
Arduino Sketch Writing MakerSwitch Tail Settings to ATMEL AT24C02 I2C EEPROM
Wiring
1. AT24C02.P01 - GND
2. AT24C02.P02 - GND
3. AT24C02.P03 - GND
4. AT24C02.P04 - GND
5. AT24C02.P05 - ArduinoUno.A4
6. AT24C02.P06 - ArduinoUno.A5
7. AT24C02.P07 - GND
8. AT24C02.P08 - 5V
Sketch
// Modified by Befun Hung on May 9, 2016
//Write setting of MakerSwitch to ATMEL AT24C02
// Address 0-7 contains ID number, address 8 contains address storing switch status value '0' or '1'
// Modified by Befun Hung on May 2, 2016
// For writing string to ATMEL AT24C02 I2C EEPROM from address 0 once and display all values in the EEPROM on serial monitor once
// The ATMEL AT24C02 I2C EEPROM with 256 bytes (2K bits) need only one byte for addressing is suitable for storing short text message such as id and ip configuration
//
// ** Original comment in simplified Chinese, the original sketch write in EEPROM numbers equal to it's address, read the values and display on serial monitor repeatedly
//直接给你个24c02简单的程序吧 不用附加库 别的带附加库也可以
//byte 换为int也行, 多数据,大于255的数据自己for循环存吧,double float论坛有教程
#include <Wire.h>
#define colPerLine 8
// define idLen according the length of id value needed
#define idLen 8
char id[idLen+1] = "25610249";
int i = 0;
int val;
void Writebyte(byte DeviceAddress, byte DataAddress, byte Data)
{
int rData = Data;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.write(rData);
Wire.endTransmission();
delay(10);
}
byte Readbyte(int DeviceAddress, byte DataAddress)
{
byte rdata = 0xFF;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.endTransmission();
Wire.requestFrom(DeviceAddress, 1);
delay(10);
if (Wire.available())
{
rdata = Wire.read();
}
delay(10);
return rdata;
}
void setup()
{
Wire.begin();
Serial.begin(115200);
for (i=0;i<256;i++) {
if (i< idLen) {
Writebyte(0x50,i,id[i]);
}
else {
// comment out the following line if values in the address greater than idLen not to be overrided with 0
Writebyte(0x50,i,0);
}
}
// Address 8 contains address storing switch status value '0' or '1'
Writebyte(0x50,8,255);
for (i=0;i<256;i++) {
if ((i%colPerLine) == 0) Serial.println("");
val = Readbyte(0x50,i);
Serial.print(val);
Serial.print(" ");
}
}
void loop()
{
// if (i > 0xFF)
// {
// i = 0x00;
// }
// Writebyte(0x50, i, i);
// val = Readbyte(0x50, i);
// i++;
// Serial.print(val);
// Serial.print(" ");
// if ((i%8) == 0) Serial.println("");
}
2016/05/02
Writing String To ATMEL AT24C02 256 Bytes (2K bits) I2C EEPROM
Sometimes I need to store default data. Storing the data in external I2C EEPROM is suitable than in ATMEGA328P built-in EEPROM when you want to change the data values.
For ATMEGA328P built-in EEPROM, you have to upload a sketch to change the default data and re-upload the sketch for use.
For external I2C EEPROM, you just unplug the IC from IC socket and replace a new one with default data you need. Uploading sketches are not needed. And the chip is cheap, it costs only 0.03 USD.
Wiring
1. AT24C02.P01 - GND
2. AT24C02.P02 - GND
3. AT24C02.P03 - GND
4. AT24C02.P04 - GND
5. AT24C02.P05 - ArduinoUno.A4
6. AT24C02.P06 - ArduinoUno.A5
7. AT24C02.P07 - GND
8. AT24C02.P08 - 5V
Sketch
// Modified by Befun Hung on May 2, 2016
// For writing string to ATMEL AT24C02 I2C EEPROM from address 0 once and display all values in the EEPROM on serial monitor once
// The ATMEL AT24C02 I2C EEPROM with 256 bytes (2K bits) need only one byte for addressing is suitable for storing short text message such as id and ip configuration
//
// ** Original comment in simplified Chinese, the original sketch write in EEPROM numbers equal to it's address, read the values and display on serial monitor repeatedly
//直接给你个24c02简单的程序吧 不用附加库 别的带附加库也可以
//byte 换为int也行, 多数据,大于255的数据自己for循环存吧,double float论坛有教程
#include <Wire.h>
#define colPerLine 8
// define idLen according the length of id value needed
#define idLen 8
char id[idLen+1] = "25613804";
int i = 0;
int val;
void Writebyte(byte DeviceAddress, byte DataAddress, byte Data)
{
int rData = Data;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.write(rData);
Wire.endTransmission();
delay(10);
}
byte Readbyte(int DeviceAddress, byte DataAddress)
{
byte rdata = 0xFF;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.endTransmission();
Wire.requestFrom(DeviceAddress, 1);
delay(10);
if (Wire.available())
{
rdata = Wire.read();
}
delay(10);
return rdata;
}
void setup()
{
Wire.begin();
Serial.begin(115200);
for (i=0;i<256;i++) {
if (i< idLen) {
Writebyte(0x50,i,id[i]);
}
else {
// comment out the following line if values in the address greater than idLen not to be overrided with 0
Writebyte(0x50,i,0);
}
}
for (i=0;i<256;i++) {
if ((i%colPerLine) == 0) Serial.println("");
val = Readbyte(0x50,i);
Serial.print(val);
Serial.print(" ");
}
}
void loop()
{
// if (i > 0xFF)
// {
// i = 0x00;
// }
// Writebyte(0x50, i, i);
// val = Readbyte(0x50, i);
// i++;
// Serial.print(val);
// Serial.print(" ");
// if ((i%8) == 0) Serial.println("");
}
For ATMEGA328P built-in EEPROM, you have to upload a sketch to change the default data and re-upload the sketch for use.
For external I2C EEPROM, you just unplug the IC from IC socket and replace a new one with default data you need. Uploading sketches are not needed. And the chip is cheap, it costs only 0.03 USD.
Wiring
1. AT24C02.P01 - GND
2. AT24C02.P02 - GND
3. AT24C02.P03 - GND
4. AT24C02.P04 - GND
5. AT24C02.P05 - ArduinoUno.A4
6. AT24C02.P06 - ArduinoUno.A5
7. AT24C02.P07 - GND
8. AT24C02.P08 - 5V
Sketch
// Modified by Befun Hung on May 2, 2016
// For writing string to ATMEL AT24C02 I2C EEPROM from address 0 once and display all values in the EEPROM on serial monitor once
// The ATMEL AT24C02 I2C EEPROM with 256 bytes (2K bits) need only one byte for addressing is suitable for storing short text message such as id and ip configuration
//
// ** Original comment in simplified Chinese, the original sketch write in EEPROM numbers equal to it's address, read the values and display on serial monitor repeatedly
//直接给你个24c02简单的程序吧 不用附加库 别的带附加库也可以
//byte 换为int也行, 多数据,大于255的数据自己for循环存吧,double float论坛有教程
#include <Wire.h>
#define colPerLine 8
// define idLen according the length of id value needed
#define idLen 8
char id[idLen+1] = "25613804";
int i = 0;
int val;
void Writebyte(byte DeviceAddress, byte DataAddress, byte Data)
{
int rData = Data;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.write(rData);
Wire.endTransmission();
delay(10);
}
byte Readbyte(int DeviceAddress, byte DataAddress)
{
byte rdata = 0xFF;
Wire.beginTransmission(DeviceAddress);
Wire.write(DataAddress);
Wire.endTransmission();
Wire.requestFrom(DeviceAddress, 1);
delay(10);
if (Wire.available())
{
rdata = Wire.read();
}
delay(10);
return rdata;
}
void setup()
{
Wire.begin();
Serial.begin(115200);
for (i=0;i<256;i++) {
if (i< idLen) {
Writebyte(0x50,i,id[i]);
}
else {
// comment out the following line if values in the address greater than idLen not to be overrided with 0
Writebyte(0x50,i,0);
}
}
for (i=0;i<256;i++) {
if ((i%colPerLine) == 0) Serial.println("");
val = Readbyte(0x50,i);
Serial.print(val);
Serial.print(" ");
}
}
void loop()
{
// if (i > 0xFF)
// {
// i = 0x00;
// }
// Writebyte(0x50, i, i);
// val = Readbyte(0x50, i);
// i++;
// Serial.print(val);
// Serial.print(" ");
// if ((i%8) == 0) Serial.println("");
}
Labels:
Arduino,
AT24C02,
ATMEGA328,
ATMEGA328P,
ATMEL,
Data,
Default,
I2C EEPROM,
String,
Value,
Write,
Writing
2016/04/29
RF Remote
Code:
// Modified by Befun Hung on Apr. 29, 2016
// 1. Use RadioHead Library
// 2. Max Length of Digits is 20 Characters.
// 3. Numbers followed by '*' to Switch On, '#' to Switch Off
// Example: 23456789* To Swith On Device 23456789, 23456789# To Switch Off Device 23456789
// Modified by Befun Hung on Oct. 28, 2014
// Blink led after sending message to notice user 5 times
#include <Keypad.h>
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
#define maxLength 20
#define keyOn '*'
#define keyOff '#'
const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {5, 4, 3, 2};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {8, 7, 6}; // connect to the column pinouts of the keypad
char keyins[maxLength+1] = "";
int i=0, j=0, sendTimes=5;
int led=13;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
Serial.begin(115200);
if (!driver.init()) Serial.println("init failed");
Serial.println("Ready!");
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.print(key);
keyins[i] = key;
i++;
if (key == keyOn || key == keyOff) {
for (j=0;j<sendTimes;j++) {
Serial.println();
send(keyins);
}
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
i = 0;
}
}
}
void send(char *message)
{
driver.send((uint8_t *) message, strlen(message));
driver.waitPacketSent();
}
// Modified by Befun Hung on Apr. 29, 2016
// 1. Use RadioHead Library
// 2. Max Length of Digits is 20 Characters.
// 3. Numbers followed by '*' to Switch On, '#' to Switch Off
// Example: 23456789* To Swith On Device 23456789, 23456789# To Switch Off Device 23456789
// Modified by Befun Hung on Oct. 28, 2014
// Blink led after sending message to notice user 5 times
#include <Keypad.h>
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
#define maxLength 20
#define keyOn '*'
#define keyOff '#'
const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {5, 4, 3, 2};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {8, 7, 6}; // connect to the column pinouts of the keypad
char keyins[maxLength+1] = "";
int i=0, j=0, sendTimes=5;
int led=13;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
Serial.begin(115200);
if (!driver.init()) Serial.println("init failed");
Serial.println("Ready!");
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.print(key);
keyins[i] = key;
i++;
if (key == keyOn || key == keyOff) {
for (j=0;j<sendTimes;j++) {
Serial.println();
send(keyins);
}
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
i = 0;
}
}
}
void send(char *message)
{
driver.send((uint8_t *) message, strlen(message));
driver.waitPacketSent();
}
2016/04/13
Burning Optiboot Bootloader to Arduino Pro Mini Using Uno R3 with ArduinoISP
This is the memorandum recording the procedure I use burning Optiboot bootloader to Arduino Pro Mini.
The procedure:
1. Upload ArduinoISP sketch to Uno R3 as any general sketch.
2. Connect Arduino Pro Mini RST to Uno R3 D10, Vcc to Vcc, Gnd to Gnd, D11 to D11, D12 to D12 and D13 to D13 respectly.
3. Select Board -> Arduino Uno, Programmer -> Arduino as ISP, Burn Bootloader from Tools menu. Wait for a minute or so, the status bar of Arduino IDE will show "Done burning bootloader.".
That's it.
No need to download Optiboot hex file from any website, to compile optiboot from source or to edit board.txt, Arduino Uno use Optiboot as its default bootloader and the hex file is include in the Arduino IDE ( the Arduino IDE I use is 1.0.5-r2). The parameters set for Uno in board.txt is suitable for all boards using ATMEGA328P-PU or ATMEGA328P-AU microcontroller.
I burn Optiboot to Arduino Pro Mini following the procedure above and upload the example blink sketch to the Arduino Pro Mini by selecting Tools -> Board -> Arduino Uno repeatly and successfully.
If Arduino Uno R3 with ArduinoISP uploaded is used, skip to step 2 directly. Step 2 can be done before or after plugging USB type A connector to computer.
Following the procedure, I can minimize the needed size of board and bytes occupied by bootloader and maximize the functions the bootloader provides such as watchdog timer.
The procedure:
1. Upload ArduinoISP sketch to Uno R3 as any general sketch.
2. Connect Arduino Pro Mini RST to Uno R3 D10, Vcc to Vcc, Gnd to Gnd, D11 to D11, D12 to D12 and D13 to D13 respectly.
3. Select Board -> Arduino Uno, Programmer -> Arduino as ISP, Burn Bootloader from Tools menu. Wait for a minute or so, the status bar of Arduino IDE will show "Done burning bootloader.".
That's it.
No need to download Optiboot hex file from any website, to compile optiboot from source or to edit board.txt, Arduino Uno use Optiboot as its default bootloader and the hex file is include in the Arduino IDE ( the Arduino IDE I use is 1.0.5-r2). The parameters set for Uno in board.txt is suitable for all boards using ATMEGA328P-PU or ATMEGA328P-AU microcontroller.
I burn Optiboot to Arduino Pro Mini following the procedure above and upload the example blink sketch to the Arduino Pro Mini by selecting Tools -> Board -> Arduino Uno repeatly and successfully.
If Arduino Uno R3 with ArduinoISP uploaded is used, skip to step 2 directly. Step 2 can be done before or after plugging USB type A connector to computer.
Following the procedure, I can minimize the needed size of board and bytes occupied by bootloader and maximize the functions the bootloader provides such as watchdog timer.
Labels:
Arduino,
Arduino as ISP,
ArduinoISP,
Bootloader,
Burn,
Burning,
Optiboot,
Pro Mini,
R3,
Uno
2016/01/13
6-digit 7-segment LED Counter Display
I need a 6-digit 7-segment LED module to display time and found Sparkfun has an example sketch for 4-digit 7-segment LED display module. So I just modify the example sketch to meet my requirement. The photos taken cannot display actual image saw by human eyes.
Photos
Parts
Arduino Uno R3
6-digit 7-segment LED Display Module KYX-3662BS
Some Wires
LED Module Pinouts
Sketch
/*
6-13-2011
Spark Fun Electronics 2011
Nathan Seidle
Original used for 4-digit 7-segment LED module
Modified by Befun Hung on Jan. 13, 2016 to Extend to 6-digit
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
4 digit 7 segment display:
http://www.sparkfun.com/products/9483
Datasheet:
http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf
This is an example of how to drive a 7 segment LED display from an ATmega without the use of current limiting resistors.
This technique is very common but requires some knowledge of electronics - you do run the risk of dumping too
much current through the segments and burning out parts of the display. If you use the stock code you should be ok, but
be careful editing the brightness values.
This code should work with all colors (red, blue, yellow, green) but the brightness will vary from one color to the next
because the forward voltage drop of each color is different. This code was written and calibrated for the red color.
This code will work with most Arduinos but you may want to re-route some of the pins.
7 segments
6 digits
1 colon
=
14 pins required for full control
*/
// LED module used in this example is KYX-3662BS which is common anode
int digit1 = 11; // 6-digit 7-segment LED pin 1
int digit2 = 10; // 6-digit 7-segment LED pin 2
int digit3 = 9; // 6-digit 7-segment LED pin 3
int digit4 = 6; // 6-digit 7-segment LED pin 4
int digit5 = 2; // 6-digit 7-segment LED pin 5
int digit6 = 12; // 6-digit 7-segment LED pin 6
//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = A1; // 6-digit 7-segment LED pin 14
int segB = 3; // 6-digit 7-segment LED pin 13
int segC = 4; // 6-digit 7-segment LED pin 12
int segD = 5; // 6-digit 7-segment LED pin 11
int segE = A0; // 6-digit 7-segment LED pin 10
int segF = 7; // 6-digit 7-segment LED pin 9
int segG = 8; // 6-digit 7-segment LED pin 8
void setup() {
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(digit1, OUTPUT);
pinMode(digit2, OUTPUT);
pinMode(digit3, OUTPUT);
pinMode(digit4, OUTPUT);
pinMode(digit5, OUTPUT);
pinMode(digit6, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
//long startTime = millis();
displayNumber(millis()/1000, 6);
displayNumber(millis()/100000, 4);
displayNumber(millis()/10000000, 2);
//while( (millis() - startTime) < 2000) {
//displayNumber(1217);
//}
//delay(1000);
}
//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off
//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//If each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)
// displayNumber() has added i parameter to display only 2 digit on specific position
void displayNumber(int toDisplay, int i) {
#define DISPLAY_BRIGHTNESS 500
#define DIGIT_ON HIGH
#define DIGIT_OFF LOW
long beginTime = millis();
for(int digit = i ; digit > i-2 ; digit--) {
// digitalWrite(13, HIGH);
//Turn on a digit for a short amount of time
switch(digit) {
// case 0:
// digitalWrite(13, HIGH);
// break;
case 1:
digitalWrite(digit1, DIGIT_ON);
break;
case 2:
digitalWrite(digit2, DIGIT_ON);
break;
case 3:
digitalWrite(digit3, DIGIT_ON);
break;
case 4:
digitalWrite(digit4, DIGIT_ON);
break;
case 5:
digitalWrite(digit5, DIGIT_ON);
break;
case 6:
digitalWrite(digit6, DIGIT_ON);
break;
}
//Turn on the right segments for this digit
lightNumber(toDisplay % 10);
toDisplay /= 10;
delayMicroseconds(DISPLAY_BRIGHTNESS); //Display this digit for a fraction of a second (between 1us and 5000us, 500 is pretty good)
//Turn off all segments
lightNumber(10);
//Turn off all digits
digitalWrite(digit1, DIGIT_OFF);
digitalWrite(digit2, DIGIT_OFF);
digitalWrite(digit3, DIGIT_OFF);
digitalWrite(digit4, DIGIT_OFF);
digitalWrite(digit5, DIGIT_OFF);
digitalWrite(digit6, DIGIT_OFF);
digitalWrite(13, LOW);
}
while( (millis() - beginTime) < 10) ; //Wait for 20ms to pass before we paint the display again
}
//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {
#define SEGMENT_ON LOW
#define SEGMENT_OFF HIGH
switch (numberToDisplay){
case 0:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_OFF);
break;
case 1:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 2:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 3:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 4:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 5:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 6:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 7:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 8:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 9:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 10:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
}
}
Photos
Parts
Arduino Uno R3
6-digit 7-segment LED Display Module KYX-3662BS
Some Wires
LED Module Pinouts
Sketch
/*
6-13-2011
Spark Fun Electronics 2011
Nathan Seidle
Original used for 4-digit 7-segment LED module
Modified by Befun Hung on Jan. 13, 2016 to Extend to 6-digit
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
4 digit 7 segment display:
http://www.sparkfun.com/products/9483
Datasheet:
http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf
This is an example of how to drive a 7 segment LED display from an ATmega without the use of current limiting resistors.
This technique is very common but requires some knowledge of electronics - you do run the risk of dumping too
much current through the segments and burning out parts of the display. If you use the stock code you should be ok, but
be careful editing the brightness values.
This code should work with all colors (red, blue, yellow, green) but the brightness will vary from one color to the next
because the forward voltage drop of each color is different. This code was written and calibrated for the red color.
This code will work with most Arduinos but you may want to re-route some of the pins.
7 segments
6 digits
1 colon
=
14 pins required for full control
*/
// LED module used in this example is KYX-3662BS which is common anode
int digit1 = 11; // 6-digit 7-segment LED pin 1
int digit2 = 10; // 6-digit 7-segment LED pin 2
int digit3 = 9; // 6-digit 7-segment LED pin 3
int digit4 = 6; // 6-digit 7-segment LED pin 4
int digit5 = 2; // 6-digit 7-segment LED pin 5
int digit6 = 12; // 6-digit 7-segment LED pin 6
//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = A1; // 6-digit 7-segment LED pin 14
int segB = 3; // 6-digit 7-segment LED pin 13
int segC = 4; // 6-digit 7-segment LED pin 12
int segD = 5; // 6-digit 7-segment LED pin 11
int segE = A0; // 6-digit 7-segment LED pin 10
int segF = 7; // 6-digit 7-segment LED pin 9
int segG = 8; // 6-digit 7-segment LED pin 8
void setup() {
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(digit1, OUTPUT);
pinMode(digit2, OUTPUT);
pinMode(digit3, OUTPUT);
pinMode(digit4, OUTPUT);
pinMode(digit5, OUTPUT);
pinMode(digit6, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
//long startTime = millis();
displayNumber(millis()/1000, 6);
displayNumber(millis()/100000, 4);
displayNumber(millis()/10000000, 2);
//while( (millis() - startTime) < 2000) {
//displayNumber(1217);
//}
//delay(1000);
}
//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off
//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//If each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)
// displayNumber() has added i parameter to display only 2 digit on specific position
void displayNumber(int toDisplay, int i) {
#define DISPLAY_BRIGHTNESS 500
#define DIGIT_ON HIGH
#define DIGIT_OFF LOW
long beginTime = millis();
for(int digit = i ; digit > i-2 ; digit--) {
// digitalWrite(13, HIGH);
//Turn on a digit for a short amount of time
switch(digit) {
// case 0:
// digitalWrite(13, HIGH);
// break;
case 1:
digitalWrite(digit1, DIGIT_ON);
break;
case 2:
digitalWrite(digit2, DIGIT_ON);
break;
case 3:
digitalWrite(digit3, DIGIT_ON);
break;
case 4:
digitalWrite(digit4, DIGIT_ON);
break;
case 5:
digitalWrite(digit5, DIGIT_ON);
break;
case 6:
digitalWrite(digit6, DIGIT_ON);
break;
}
//Turn on the right segments for this digit
lightNumber(toDisplay % 10);
toDisplay /= 10;
delayMicroseconds(DISPLAY_BRIGHTNESS); //Display this digit for a fraction of a second (between 1us and 5000us, 500 is pretty good)
//Turn off all segments
lightNumber(10);
//Turn off all digits
digitalWrite(digit1, DIGIT_OFF);
digitalWrite(digit2, DIGIT_OFF);
digitalWrite(digit3, DIGIT_OFF);
digitalWrite(digit4, DIGIT_OFF);
digitalWrite(digit5, DIGIT_OFF);
digitalWrite(digit6, DIGIT_OFF);
digitalWrite(13, LOW);
}
while( (millis() - beginTime) < 10) ; //Wait for 20ms to pass before we paint the display again
}
//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {
#define SEGMENT_ON LOW
#define SEGMENT_OFF HIGH
switch (numberToDisplay){
case 0:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_OFF);
break;
case 1:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 2:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 3:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 4:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 5:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 6:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 7:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 8:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 9:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 10:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
}
}
Labels:
6-digit,
7-segment,
Counter,
Display,
KYX-3662,
KYX-3662AS,
KYX-3662AS/BS,
KYX-3662BS,
LED,
Module
2016/01/02
Burning Arduino Uno Optiboot Bootloader Using Duemilanove Compatible
This is the note recording the procedure I used burning the Optiboot bootloader to ATMEGA328P-PU microcontroller.
Tools used:
1. Duemilanove ( no need for adding a 10uF capacitor between rest and ground) compatible Justduino TTL ( I made a few years ago) with ArduinoISP uploaded (since Justduino TTL been made).
2. AVR ISP Shield (no need for wiring, more productive and error free).
3. Arduino IDE 0.022 and 0.023 (In Arduino IDE 1.0 and above, ArduinoISP sketch need to be modified, compiled and uploaded) .
Procedure:
1. Stack AVR ISP Shield upon Justduino TTL.
2. Power the Justduino TTL by plugging FT232 Cable compatible cable into USB port on computer, the PLS led on the AVR ISP Shield starts breathing:) ( Kit Review - AVR ISP Shield on tronixstuff.com) .
3. Open Arduino IDE 0.022 or 0.023 (I used both without fail).
4. Load ATMEGA328P-PU IC upon 28-pin ZIF socket and pull ZIF lever down.
5. Select the items in the Tools > Serial Port menus that correspond to the board you are using as the programmer.
6. Select the item in the Tools > Board menu that corresponds to the board (Arduino Uno) on which you want to burn the bootloader.
7. Select the w/ Arduino as ISP in the Tools>Burn Bootloader.
8. The PROG led will light on during the burning process, the process takes about one minute.
That's it. Easy!
After inserting the ATMEGA328P-PU upon the socket on the Justduino TTL, the D13 led doesn't blink the same way as the new Arduino Uno dose. I just compile the example blink sketch and upload it in Arduino IDE 1.0.5. Now, the D13 led blinks the same way as the new Arduino Uno does.
I find that I cannot re-burn the bootloader to the ATMEGA328P-PU.
Next Step:
I want to buy some Yamaichi IC51-0324-1498 socket and make some TQFP32 to TQFP28 adapters to stack upon the AVR ISP Shield for burning Optiboot bootloader to ATMEGA328P-AU for use on the coming projects featuring watchdog and software reset.
Tools used:
1. Duemilanove ( no need for adding a 10uF capacitor between rest and ground) compatible Justduino TTL ( I made a few years ago) with ArduinoISP uploaded (since Justduino TTL been made).
2. AVR ISP Shield (no need for wiring, more productive and error free).
3. Arduino IDE 0.022 and 0.023 (In Arduino IDE 1.0 and above, ArduinoISP sketch need to be modified, compiled and uploaded) .
Procedure:
1. Stack AVR ISP Shield upon Justduino TTL.
2. Power the Justduino TTL by plugging FT232 Cable compatible cable into USB port on computer, the PLS led on the AVR ISP Shield starts breathing:) ( Kit Review - AVR ISP Shield on tronixstuff.com) .
3. Open Arduino IDE 0.022 or 0.023 (I used both without fail).
4. Load ATMEGA328P-PU IC upon 28-pin ZIF socket and pull ZIF lever down.
5. Select the items in the Tools > Serial Port menus that correspond to the board you are using as the programmer.
6. Select the item in the Tools > Board menu that corresponds to the board (Arduino Uno) on which you want to burn the bootloader.
7. Select the w/ Arduino as ISP in the Tools>Burn Bootloader.
8. The PROG led will light on during the burning process, the process takes about one minute.
That's it. Easy!
After inserting the ATMEGA328P-PU upon the socket on the Justduino TTL, the D13 led doesn't blink the same way as the new Arduino Uno dose. I just compile the example blink sketch and upload it in Arduino IDE 1.0.5. Now, the D13 led blinks the same way as the new Arduino Uno does.
I find that I cannot re-burn the bootloader to the ATMEGA328P-PU.
Next Step:
I want to buy some Yamaichi IC51-0324-1498 socket and make some TQFP32 to TQFP28 adapters to stack upon the AVR ISP Shield for burning Optiboot bootloader to ATMEGA328P-AU for use on the coming projects featuring watchdog and software reset.
Labels:
Arduino,
ATMEGA328P-AU,
ATMEGA328P-PU,
Bootloader,
Burn,
Burning,
Duemilanove,
IC51-032401498,
Optiboot,
R3,
Uno
Subscribe to:
Posts (Atom)