With the rest i'm finished, i printed the parts and do all de rest, now i cannot upload a firmware and dont know what and how to change, that it works on my board.
I hope you understand what i mean, i'n not a programmer but i want to learn this, its a really cheap project that helps handicaped people a lot to live their life! Would be great if anyone could help me with this project!
i dont find the same Arduino Board ("Arduino Pro Micro (5V version)")
The Arduino Micro should be a nearly-identical replacement for the "Pro Micro" - they have the same chip, but the newer board breaks out more of the pins, has a reset switch, and etc.
The "pro micro" was never an official Arduino board - you can still buy them from Sparkfun (the original developer) https://www.sparkfun.com/products/12640, and maybe from eBay (but be careful not to get one of the much-more-common "Pro Mini" clones.)
Yeah, thats what i was thinking too, but i dont know where to start.
What you mean, what should i post? Just the "main-code" from the arduino file?
/*
Basic example for the T-Rex Mouse project
based on the 'HID Joystick Mouse Example' by Jim Lindblom (2012)
by: T. Wirtl
date: 16/10/2015
license: MIT License - Feel free to use this code for any purpose.
No restrictions. Just keep this license if you go on to use this
code in your future endeavors! Reuse and share.
*/
#include "TimerOne.h"
#define X_AXIS_PIN A0
#define Y_AXIS_PIN A1
#define BUTTON_PIN 2
#define SENSOR_PIN 3
#define TIMER_OVERRUN_USEC 100000 // Timer overrun in usecs (defines the sensitivity of the sensor)
#define AXIS_SENSITIVITY 30 // Higher sensitivity value = slower mouse, should be <= about 500
int vertZero, horzZero; // Stores the initial value of each axis, usually around 512
int vertValue, horzValue; // Stores current analog output of each axis
volatile int clickLeft = 0;
// On timer overrun
void timerIrq()
{
clickLeft = 0; // Let's handle this in the main loop
Timer1.stop();
}
// On rising edge of the sensor pin
void sensorIrq()
{
TCNT1 = 1; // Timer restart without triggering the interrupt
if (!clickLeft)
{
Timer1.start(); // Start the timer if not already started
}
clickLeft = 1; // Let's handle this in the main loop
}
void setup()
{
// Pin config
pinMode(X_AXIS_PIN, INPUT); // Set both analog pins as inputs
pinMode(Y_AXIS_PIN, INPUT);
pinMode(BUTTON_PIN, INPUT); // Pin for the connected button
pinMode(SENSOR_PIN, INPUT); // Pin for the sensor
digitalWrite(BUTTON_PIN, HIGH); // Enable pull-up on button pin (active low)
// Timer initialization
Timer1.initialize(TIMER_OVERRUN_USEC);
Timer1.attachInterrupt(timerIrq);
attachInterrupt(0, sensorIrq, RISING);
// Axis calibration
delay(1000); // short delay to let outputs settle
vertZero = analogRead(Y_AXIS_PIN); // get the initial values
horzZero = analogRead(X_AXIS_PIN); // Joystick should be in neutral position when reading these
}
void loop()
{
static int mouseClickFlagRight = 0;
static int mouseClickFlagLeft = 0;
// Get ADC vals
vertValue = (analogRead(Y_AXIS_PIN) - vertZero); // read vertical offset
horzValue = (analogRead(X_AXIS_PIN) - horzZero); // read horizontal offset
// Axis movement
if (vertValue != 0)
{
Mouse.move(0, vertValue/AXIS_SENSITIVITY, 0); // move mouse on y axis
}
if (horzValue != 0)
{
Mouse.move(horzValue/AXIS_SENSITIVITY, 0, 0); // move mouse on x axis
}
// Right mouse button
if ((digitalRead(BUTTON_PIN) == 0) && (!mouseClickFlagRight)) // if the joystick button is pressed
{
mouseClickFlagRight = 1;
Mouse.press(MOUSE_RIGHT); // click the left button down
}
else if ((digitalRead(BUTTON_PIN))&&(mouseClickFlagRight)) // if the joystick button is not pressed
{
mouseClickFlagRight = 0;
Mouse.release(MOUSE_RIGHT); // release the left button
}
// Left mouse button
if ((clickLeft) && (!mouseClickFlagLeft)) // if the joystick button is pressed
{
mouseClickFlagLeft = 1;
Mouse.press(MOUSE_LEFT); // click the left button down
}
else if ((!clickLeft)&&(mouseClickFlagLeft)) // if the joystick button is not pressed
{
mouseClickFlagLeft = 0;
Mouse.release(MOUSE_LEFT); // release the left button
}
}
This is the Main-filecode or whats called it? but if i click on the open symbol there are much more files.
The file is in the attachments.
@ westfw
i found these, but i was thinking i would to try to do it with the micro, it cannot be that hard. But after 2 hours of google, for me was the best way to ask here in the forum how to start in adruino for a problem like this.
Atmega32u4 is the only thing that counts when it comes to firmware.
Fuse settings will allow you to change how the chip behaves with different crystals added
For example the Arduino Leonardo runs at 16 MHz because of the crystal oscillator attached
The 3v Arduino Pro Micro runs at 8 MHz and requires different fuses to be set so you will need to
your board Arduino Pro Micro runs exactly the same with exactly the same crystal so you could use the same fuses settings...
So burning the bootloader for the Arduino Leonardo (Set for 5V and 16MHz default) will work great with the Arduino Pro Micro 5V 16MHz version!
You say you cannot upload the program to the Micro board.
You need to post the error messages that you get?
What Arduino board have you selected in the Arduino IDE?
What version of the Arduino IDE are you using?
Have you tried uploading one of the simple example programs from the Arduino IDE?
Was that successful?
This would help us to know whether you have a general problem or whether it is specific to the program you are hoping to use.
If i try to veryfi the firmware with choose "Adruino / Genuino Micro" it gives me this error on "arduino 1.6.9":
Build options changed, rebuilding all
C:\Users\anonym.anonym\Desktop\t_rex_mouse\t_rex_mouse.ino:11:22: fatal error: TimerOne.h: No such file or directory
#include "TimerOne.h"
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Micro.
what am i doing wrong?
@ zhomeslice
Should i try to do bootloader? and after that install the firmware? wich board should i chose?
Robin2:
Have you tried uploading one of the simple example programs from the Arduino IDE?
Was that successful?
This would help us to know whether you have a general problem or whether it is specific to the program you are hoping to use.
Yeah!! I'm a step further
I includet the hid, the mouse and the timerone libary, now it moves!
but it seems to be as i have to change more things that it works good. The sensor is not working yet, dont know why. And on y axe the mouse goes wrong way, but i try to find a value , i can change for these.
Edit:
How can i change the y axe movement of my mouse upside-down in the mouse.move(0,0,0) function, or do i have to go upper where it's getting the zero-values?
// Axis calibration
delay(1000); // short delay to let outputs settle
vertZero = analogRead(Y_AXIS_PIN); // get the initial values
horzZero = analogRead(X_AXIS_PIN); // Joystick should be in neutral position when reading these
}
void loop()
{
static int mouseClickFlagRight = 0;
static int mouseClickFlagLeft = 0;
// Get ADC vals
vertValue = (analogRead(Y_AXIS_PIN) - vertZero); // read vertical offset
horzValue = (analogRead(X_AXIS_PIN) - horzZero); // read horizontal offset
// Axis movement
if (vertValue != 1)
{
Mouse.move(0, vertValue/AXIS_SENSITIVITY, 0); // move mouse on y axis
}
if (horzValue != 0)
{
Mouse.move(horzValue/AXIS_SENSITIVITY, 0, 0); // move mouse on x axis
}
Edit 2:
Ok, found set a "-" before vertValue/AXIS_SENSITIVITY and it works:
if (vertValue != 1)
{
Mouse.move(0, -vertValue/AXIS_SENSITIVITY, 0); // move mouse on y axis
}
So, i've made it. I found out that the sensor only works on 5V but the joystick works also at 3.3V, now the rest was just a little bit of change in the x and y axes and change values of sensitivity.
So all good for now. Very happy, thanks for your help guys!