Button operated led plus pulse out for games controller

Hi, I am new to XOD & Arduino programming and would like to develop a push button that turns an LED on and off but also develops a pulse out that can be used to activate an option in a games controller, can anyone offer advice?

Have you been through the built-in tutorial? That should answer most of your questions for this. If you still need help after the tutorial, we would need more details before we could help. I would recommend starting the program to see how far you can get, then ask for help fixing any issues you run into. This is the best way for you to actually learn the process instead of us just giving you the answer for each problem.

For example, if you want a pulse each time the button is pushed, you only need to connect a second wire to the button output. If you want a pulse each time the light turns on, then you only need a second wire from the pin controlling the LED. If you want a pulse when the LED turns off, you need a second wire from the pin controlling the LED and connect that to a ‘not’ node (or connected it to a ‘pulse-on-false node’, which would give the same result).

1 Like

Thanks Gweimer, I have got the LED turning on and off from the switch OK, am still working on the serial side of it. What I want to do is whenever the button is pushed to either turn the LED on or off a serial pulse is sent via a USB cable to a games controller to turn on and off a particular feature in the game, like changing gear in truck simulator. I will go through the tutorial again as well, must have missed something in it. I am 82 and my brain is slowing down.
Many thanks for your advice

1 Like

Hi Gwiener keep getting the following error running the tutorial that says “Error
Maximum call stack size exceeded
The error was not caught, which is a bug. Report the issue to XOD developers.”

If it is any help I am trying to achieve what the following unit does but using XOD to do it.

USB1

1 Like

Which part of the tutorial is getting that error?

It was when I went to simulate in step 2 but I have rebooted my pc since then and it appears to be OK now

Gweimer, while doing the tutorial I tried to do an example print but I keep getting the following error

Generating C++ code for simulation…
Building…
/ws/sketchbook/b2426430d01958893fc6956ac3cb2134b91600a1e112633d7f01659612e98486/sketch/sketch.ino:1095:27: error: use of undeclared identifier ‘SERIAL_PORT_HARDWARE’
auto serial = SERIAL_PORT_HARDWARE;
^
/ws/sketchbook/b2426430d01958893fc6956ac3cb2134b91600a1e112633d7f01659612e98486/sketch/sketch.ino:1417:10: fatal error: ‘SoftwareSerial.h’ file not found
#include <SoftwareSerial.h>
^~~~~~~~~~~~~~~~~~
2 errors generated.
shared:ERROR: ‘/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=1 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/libcxx -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/lib/libcxxabi/include -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/compat -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/libc -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/local/include -DLLVM_ROOT=/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/bin -DARDUINO_WASM_SIMULATION -DARDUINO_ARCH_WASM -O2 -std=c++11 -nostdlib -fno-exceptions -fno-rtti -c -I/tmp/arduino-sketch-1B20E9E961E8708DA9C80930D2369F81/sketch -I/ws/arduino_data/packages/xod/hardware/wasm/0.3.2/cores/simulation -I/ws/arduino_data/packages/xod/hardware/wasm/0.3.2/variants/simulation -DEMSCRIPTEN /tmp/arduino-sketch-1B20E9E961E8708DA9C80930D2369F81/sketch/sketch.ino.cpp -Xclang -isystem/ws/arduino_data/packages/xod/tools/emscripten/1.39.2/emscripten/system/include/SDL -c -o /dev/null -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr’ failed (1)
Error during build: exit status 1

You are trying to use the simulator with hardware nodes. This can never work because the simulator doesn’t have that hardware. For something like serial connection, you will not be able to use the simulator. For something like buttons and LCD screens, you can replace the button node with a tweak node for input and the LCD node with a watch node for display so you can use the simulator. Sensors with numeric output can also be replaced with tweak nodes. Select the appropriate tweak node (boolean for button, numeric for analog sensor, etc.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.