-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to run button_event.cpp
gives error undefined reference to 'main'
and deletes the file.
#38
Comments
Hmm.. can you retry with I think it's because you skipped the output program name. So g++ thought If the file was deleted, pull the repository and try again. |
Thank you. That throws no errors and creates a But when I execute the file with
|
|
|
and
|
Thank you. I have another question. Kind of outside the scope if you don't mind too much... |
Ok, if that fix your problem, About circuit, I think you should complete the circuit if I understand your description correctly. Or you can just try both ways and see if it works :). |
Right. Have you used a Jetson for buttons and LEDs? If I have a wire going from pin 11 to an LED, where does the other LED's wire get connected to complete the circuit? I thought it was the ground, but I didn't get anything from the scripts with a button and LED connected to the right GPIO pins and ground pins. |
When using pin 1, which is a 3.3V pin and a ground pin (6) I get light out of an LED with two resistors(?). Output of that script. $ ./button_event I even tried a gpio Python library and a script to try to get a single LED to turn on and that didn't work. Following this tutorial. When I check the pins with an electrometer pins 7 and 11 have about 0.1V, and they don't seem to be changing when the 'OFF, ON, OFF, ON' signals are supposedly being sent to the pins. Weird! I wonder what is wrong with my Jetson. The electrometer reads 3.3V and the 3.3V pins. |
Alright, I think I need to buy PN2222 transistors to use the gpio pins on this fucking thing. Pardon my French. Although in this tutorial he doesn't seem to be using that type of transistor. UPDATE: I just bought a few transistors at the computer store. They didn't work. I can't use anything in Python or C++ to get the gpio pins to control an LED. |
About: Is this result from the first setup(the first image I posted)? or the second setup? I'm assuming it's from the second setup. Can you retry it with the first setup? If it's from the first setup, something is wrong with your circuit probably. In the first setup pin 11 should be HIGH when the button is not pushed even without the program because pin 11 is connected to 3.3V pin. And getting warning is bit weird too. Maybe is it because you tested the same pin with python and didn't cleanup? Hmm... By the way, I didn't know somebody wrote a tutorial using this library. I'm really glad! |
Ok, create a new .cpp file to check the input first. #include <signal.h>
#include <chrono>
#include <iostream>
#include <thread>
#include <JetsonGPIO.h>
using namespace std;
static bool end_this_program = false;
inline void delay(int s) { this_thread::sleep_for(chrono::seconds(s)); }
void signalHandler(int s) { end_this_program = true; }
int main()
{
// When CTRL+C pressed, signalHandler will be called
signal(SIGINT, signalHandler);
// Pin Definitions
int led_pin = 7; // BOARD pin 7
int but_pin = 11; // BOARD pin 11
// Pin Setup.
GPIO::setmode(GPIO::BOARD);
// set pin as an output pin with optional initial state of LOW
GPIO::setup(led_pin, GPIO::OUT, GPIO::LOW);
GPIO::setup(but_pin, GPIO::IN);
cout << "input test! Press CTRL+C to exit" << endl;
while (!end_this_program) {
GPIO::output(led_pin, GPIO::HIGH);
std::cout << "should be HIGH" << std::endl;
std::cout << "input: " << GPIO::input(but_pin) << std::endl;
delay(1);
GPIO::output(led_pin, GPIO::LOW);
std::cout << "should be LOW" << std::endl;
std::cout << "input: " << GPIO::input(but_pin) << std::endl;
delay(1);
}
GPIO::cleanup();
return 0;
}
If 1, 2, 3 works, everything is normal. |
I tried all three. I got the same output each time. Pin 7 and pin 11 connected
11 to 3.3V has the same output as above. Input: 0 11 to ground is also same. Input: 0 From your comment above
It seems like the pins have 0.1V unless they are the 3.3V or 5V. The gpio pins are just dead metal that don't have any signal. |
Hmm.. so that means the input is not working... When you are running the program, open an another terminal and On the jetson-io, can you see pin 7 and 11 are using? |
You want me to run this with Python?
Sorry, I don't know what you're asking exactly. |
about jetson-io(https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/hw_setup_jetson_io.html) If you set the pins input/output(by python or c++) probably you can see it from jetson-io. |
Hmm... but if the program is running without throwing any error, I think the software is running correctly. |
If it's not something burned out with the hardware it must be a problem with Jetpack or pin configuration option that is obviously over my head. |
Hmm.. Honestly I don't know how to investigate further, sorry. If you cannot control your GPIO with the official python library too, |
I got the screen with Mine looks like yours. |
When you are running the program, open an another terminal and run jetson-io. If you set the pins input/output(by python or c++), probably you can see it from jetson-io(unused to input or output). At the end of the program, JetsonGPIO will clean up all channels that were used. So if you need to run jetson-io while the program is running. It's just checking if the pin setting is changed or not. |
I've managed to more or less solve the problem and get blinking lights controlled by Python and C++ scripts, like the ones in your repo. On this site I don't know if this is just something with the Xavier. |
Thank you for the information. On the site you linked: According to the link, looks like pin 3, 5, 8, 10, 27, 28 cannot be used as GPIO in Xavier by the default. Thank you for the information again. And I'm glad that the library works on your device! |
I didn't look at all your scripts. Do any of them use stepper motors? |
There is no sample script using step motors.
I'm not very familiar with hardware or circuits, so I cannot give any advice about that kind of stuff. |
The text was updated successfully, but these errors were encountered: