Difference between revisions of "Blog 22"
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
*Arduino |
*Arduino |
||
*[https://github.com/PaulStoffregen/Time Time Library] |
*[https://github.com/PaulStoffregen/Time Time Library] |
||
*[https://processing.org/ Processing] |
|||
== Simple Example code == |
== Simple Example code == |
||
Line 82: | Line 83: | ||
*[[DIO protocol]] |
*[[DIO protocol]] |
||
*[[Blog 21]] - The Raspberry Pi Version of the above projects. |
*[[Blog 21]] - The Raspberry Pi Version of the above projects. |
||
*[https://oopsohno.wordpress.com/2014/04/11/how-to-get-the-arduino-time-library-up-and-going/ Guide from oopsohno: How to get the arduino time library up and going] |
|||
*[[Blog list]] |
*[[Blog list]] |
Revision as of 15:22, 24 December 2015
!BETA!
Hardware used on Arduino:
- DIO | (DIO)
- Jumper cables M-F
- 4 PIN I2C cable F-F
- Analog meter
Programmed with:
- Arduino
- Time Library
- Processing
Simple Example code
In this code I will show how you can make the Analog meter pointer, be at 50% for ten seconds and being off for 10 seconds. It is just easy code to use to check if the connection works between meter, dio and arduino.
#define DIO 0x42 #include <Wire.h> void setup() { Wire.begin(); // wake up I2C bus Serial.begin(9600); set_var(0x42, 0x30, 0x01); set_var(0x42, 0x5f, 0x01); } byte get_var(byte address, byte reg) { byte value; Wire.beginTransmission(address); Wire.write(reg); Wire.endTransmission(); delayMicroseconds (10); Wire.requestFrom(DIO, 1); value = Wire.read(); return value; } void set_var(byte address, byte reg, byte value) { Wire.beginTransmission(address); delayMicroseconds (10); Wire.write(reg); delayMicroseconds (10); Wire.write(value); Wire.endTransmission(); } void loop() { unsigned long DIOAddress; char buf[32]; set_var(0x42, 0x50, 0x80); DIOAddress = get_var(0x50, 0xb); sprintf (buf, "PWM80: A:%d \r\n", DIOAddress); Serial.write (buf); delay(10000); set_var(0x42, 0x50, 0x00); DIOAddress = get_var(0x50, 0xb); sprintf (buf, "PWM0 : A:%d \r\n", DIOAddress); Serial.write (buf); delay(10000); }
DIO Analog Meter - Clock
DIO Analog Meter - Timer
Useful links
- DIO
- DIO protocol
- Blog 21 - The Raspberry Pi Version of the above projects.
- Guide from oopsohno: How to get the arduino time library up and going
- Blog list