
Originally Posted by
PaulStoffregen
Hi Paul - thanks for the rapid response. I went back to the drawing board, using your bare Teensyduino materials (instead of the teensy-template). Still, I get the same problem.
Code:
/Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121 -I. -c -o main.o main.cpp
main.cpp: In function 'int main()':
main.cpp:29:3: error: 'Joystick' was not declared in this scope
Joystick.X(analogRead(3));
^
make: *** [main.o] Error 1
My code now looks like this.
Code:
#define USB_HID
#include "WProgram.h"
extern "C" int main(void)
{
#ifdef USING_MAKEFILE
// To use Teensy 3.0 without Arduino, simply put your code here.
// For example:
//blink test (detect something happened)
pinMode(13, OUTPUT);
int i = 3;
while (i > 0) {
digitalWriteFast(13, HIGH);
delay(500);
digitalWriteFast(13, LOW);
delay(500);
i--;
}
//now do joystick things?
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
while (1)
{
// read analog inputs and set X-Y position
Joystick.X(analogRead(3));
Joystick.Y(analogRead(2));
// read the digital inputs and set the buttons
Joystick.button(1, digitalRead(0));
Joystick.button(2, digitalRead(1));
}
#else
// Arduino's main() function just calls setup() and loop()....
setup();
while (1) {
loop();
yield();
}
#endif
}
My question remains the same... what does selecting Tools > USB Type > Joystick actually *do*, and how do I replicate it sans the Arduino IDE?
Would really appreciate your help!