Today i make some change at the code to get my Arduino Leonardo work with OSD Battery Monitor from
HoolyHoo
Great work Hoolyhoo !!!!!!!!!!
http://www.sudomod.com/forum/viewtopic.php?f=22&t=2970
OSD Battery Monitor from HoolyHoo
You see the Symbol at the TV
The Arduino Leonardo

Now i change from VCC 10KOHM A0 conection to GND 10KOHM A0 and thze animation start

It start to shut down
and it is out
The Code is now:
Code: Select all
#include "HID-Project.h"
#define NUM_BUTTONS 17
#define BTN_UP 0
#define BTN_DOWN 1
#define BTN_LEFT 2
#define BTN_RIGHT 3
#define BTN_A 4
#define BTN_START 5
#define BTN_Y 6
#define BTN_L1 7
#define BTN_X 8
#define BTN_R1 9
#define BTN_B 10
#define BTN_SELECT 14
const int ledPin = 16;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
char i;
void setup()
{
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, OUTPUT);
Gamepad.begin();
Serial.begin(115200);
}
void loop()
{
bool down = !digitalRead(BTN_DOWN);
bool up = !digitalRead(BTN_UP);
bool left = !digitalRead(BTN_LEFT);
bool right = !digitalRead(BTN_RIGHT);
Gamepad.dPad1(GAMEPAD_DPAD_CENTERED);
if(down) {
Gamepad.dPad1(GAMEPAD_DPAD_DOWN);
if(left) {
Gamepad.dPad1(GAMEPAD_DPAD_DOWN_LEFT);
}if(right) {
Gamepad.dPad1(GAMEPAD_DPAD_DOWN_RIGHT);
}
}else if(up) {
Gamepad.dPad1(GAMEPAD_DPAD_UP);
if(left) {
Gamepad.dPad1(GAMEPAD_DPAD_UP_LEFT);
}if(right) {
Gamepad.dPad1(GAMEPAD_DPAD_UP_RIGHT);
}
}else if(left) {
Gamepad.dPad1(GAMEPAD_DPAD_LEFT);
}else if(right) {
Gamepad.dPad1(GAMEPAD_DPAD_RIGHT);
}
for(int i = 4; i <16; i++)
{
if(!digitalRead(i)) {
Gamepad.press(i);
}else {
Gamepad.release(i);
}
}
Gamepad.write();
int sensorValue = analogRead(A0); // read the input on analog pin 0:
//Serial.println(sensorValue); // print out the value you read
float voltage = sensorValue * (4.88 / 1023.00);
//Serial.println(voltage);
if(Serial.available())
{
i=Serial.read();
}
if(i=='1')
{
Serial.println(sensorValue);
}
i='0';
if (voltage > 4.5)
{
digitalWrite(16, HIGH);
}
else
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
}
delay(10);
}
You only need to flash your Arduino Leonardo micro Pro with the Code and install everithing from the guide from HoolyHoo!
Have Fun
Pin Out after Flash with arduinio over USB:
left site
PIN___Find at Gamepad detection____I use for
TXD__HAT 0 Down_______________Down
RXT__HAT 0 UP__________________UP
GND
GND
2____HAT 0 LEFT________________Left
3____HAT 0 RIGHT_______________Right
4____Button 3__________________A
5____Button 4 __________________Start
6____Button 5 __________________Y
7____Button 6 __________________L1
8____Button 7__________________X
9____Button 8__________________R1
right site
PIN__Find at Gamepad detection____I use for
raw
gnd
rst
vcc
A3
A2
A1
A0
used for Voltmeter with 10KOhm
15___Button 14_______________Select
14___Button 13_______________Not used
16___
no conection output 5V for Game Gear LED
10___Button 9 ________________B