Hello!
I have tried the USBKeyboard example from the v-usb library (Google Code Archive - Long-term storage for Google Code Project Hosting.) on an Atmega8 with a 16mhz crystal
#include "UsbKeyboard.h"
#define BUTTON_PIN 12
// If the timer isr is corrected
// to not take so long change this to 0.
#define BYPASS_TIMER_ISR 1
void setup() {
pinMode(BUTTON_PIN, INPUT);
digitalWrite(BUTTON_PIN, HIGH);
#if BYPASS_TIMER_ISR
// disable timer 0 overflow interrupt (used for millis)
TIMSK0&=!(1<<TOIE0); // ++
#endif
}
#if BYPASS_TIMER_ISR
void delayMs(unsigned int ms) {
/*
*/
for (int i = 0; i < ms; i++) {
delayMicroseconds(1000);
}
}
#endif
void loop() {
UsbKeyboard.update();
digitalWrite(13, !digitalRead(13));
if (digitalRead(BUTTON_PIN) == 0) {
//UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
UsbKeyboard.sendKeyStroke(KEY_H);
UsbKeyboard.sendKeyStroke(KEY_E);
UsbKeyboard.sendKeyStroke(KEY_L);
UsbKeyboard.sendKeyStroke(KEY_L);
UsbKeyboard.sendKeyStroke(KEY_O);
UsbKeyboard.sendKeyStroke(KEY_SPACE);
UsbKeyboard.sendKeyStroke(KEY_W);
UsbKeyboard.sendKeyStroke(KEY_O);
UsbKeyboard.sendKeyStroke(KEY_R);
UsbKeyboard.sendKeyStroke(KEY_L);
UsbKeyboard.sendKeyStroke(KEY_D);
//UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
UsbKeyboard.sendKeyStroke(KEY_ENTER);
#if BYPASS_TIMER_ISR // check if timer isr fixed.
delayMs(20);
#else
delay(20);
#endif
}
}
but when I compile, i get this error:
UsbKeyboardDemo1.cpp:19:3: error: ‘TIMSK0’ was not declared in this scope
When I compile it for the Arduino Uno it does work. It does the same with other sketches i have tried where 'TIMSK0' is used.
I wonder if i have to change something that is different on the atmega8 timer.
I would be glad if somebody could help me