Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Nintendo.h"
- /* This code uses the Nicohood Library
- * Original code by Simple Controllers
- * Code edited by TimpZ
- * Use this code at your own risk
- */
- //This makes the controller bidirection data line on pin number8
- CGamecubeConsole gcConsole(8); //Defines a "Gamecube Console" sending data to the console on pin 8
- Gamecube_Data_t d = defaultGamecubeData; //Structure for data to be sent to console
- //This is needed but you don't need a controller on pin 7
- CGamecubeController gcController(7);
- const int X = 22;
- unsigned long pMic = 0;
- const long interval = 116669;
- const long firstPress = 0;
- const long secPress = 66668;
- bool btnPressOld = 0;
- void setup()
- {
- //This is establishing the pin assignments up there to input pins
- pinMode(X, INPUT_PULLUP);
- //This is needed to run the code.
- gcController.read();
- pinMode(LED_BUILTIN, OUTPUT);
- }
- void loop()
- {
- //This resets and establishes all the values after the controller sends them to the console and helps with initial "zeroing"
- int pinX = 0;
- unsigned long cMic = micros();
- bool btnPress = 0;
- if (digitalRead(X) == LOW){
- btnPress = 1;
- if (btnPress != btnPressOld && btnPressOld == 0){
- btnPressOld = btnPress;
- pMic = cMic;
- }
- if(cMic - pMic >= interval){
- pMic = cMic;
- }
- if (cMic - pMic >= firstPress && cMic - pMic < secPress){
- digitalWrite(LED_BUILTIN, LOW);
- }
- else if (cMic - pMic >= secPress && cMic - pMic < interval){
- digitalWrite(LED_BUILTIN, HIGH);
- }
- }
- if (btnPress != btnPressOld && btnPressOld == 1){
- btnPressOld = btnPress;
- }
- // Enable the line below to see the issue
- //gcConsole.write(d);
- }
Advertisement
Add Comment
Please, Sign In to add comment