please choosego to mobile | Continue to access the PC version
Author: linga51

GPIO library - WiringPi

[Copy link]

0

threads

6

posts

114

credits

Registered member

Rank: 2

credits
114
Published in 2016-2-17 15:52:37 from mobile | Show all floors
Great ..  just a question.  What do you mean with "don't have gpio-sunxi - module loaded". What do we have to care of? Something in startup?  Is there some command to avoid loading that module?

2

threads

144

posts

1066

credits

Gold member

Rank: 6Rank: 6

credits
1066
Published in 2016-2-17 17:21:41 | Show all floors
domcat replied at 2016-2-17 15:52
Great ..  just a question.  What do you mean with "don't have gpio-sunxi - module loaded". What do w ...

Well, it depends on your distro. I suppose most distros have it compiled as a module, so all you have to do is make sure the module is not loaded -- check with lsmod, use rmmod to unload the module if it is loaded.

0

threads

5

posts

70

credits

Registered member

Rank: 2

credits
70
Published in 2016-2-17 17:26:31 | Show all floors
Edited by Impressive at 2016-2-17 17:30
WereCatf replied at 2016-2-17 00:51
You need to know whether you need a pull-up resistor or a pull-down resistor. If whatever you've c ...

So, I tried to use pull-up and pull-down resistor in this C code, but it didn't work:
  1. #include <wiringPi.h>
  2. #include <stdio.h>
  3. #include <drcSerial.h>

  4. int main (void)
  5. {
  6.   wiringPiSetup();
  7.   pinMode(6, OUTPUT);
  8.   pinMode(7, OUTPUT);
  9.   pinMode(8, INPUT);
  10.   digitalWrite(7, HIGH);
  11.   pullUpDnControl (8, PUD_DOWN) ;
  12.   if (digitalRead(8) == HIGH)
  13.   {
  14.     digitalWrite(6, HIGH);
  15.     delay(500);
  16.     digitalWrite(6,  LOW);
  17.     delay(500);
  18.     digitalWrite(6, HIGH);
  19.     delay(500);
  20.     digitalWrite(6,  LOW);
  21.     delay(500);
  22.   }
  23.   else
  24.   {
  25.     digitalWrite(6, HIGH);
  26.     delay(2500);
  27.     digitalWrite(6,  LOW);
  28.     delay(500);
  29.   }
  30.   return 0;
  31. }
Copy code
  1. pinMode(6, OUTPUT);
Copy code
It's a LED
  1. pinMode(7, OUTPUT);
  2.   pinMode(8, INPUT);
Copy code
Beetwen this pins I puts the button.
So, when I switch button on/off it didn't work. LED flashed at random. I hope someone will find out how to deal with pin INPUT and button...

2

threads

144

posts

1066

credits

Gold member

Rank: 6Rank: 6

credits
1066
Published in 2016-2-17 19:05:38 | Show all floors
Impressive replied at 2016-2-17 17:26
So, I tried to use pull-up and pull-down resistor in this C code, but it didn't work:
It's a LED
Be ...

Yeah, it seems there is a bug in the WiringOP - library. I have merged a fix for pull-up/pull-down in my git-repo, compile WiringOP from there and it should work.

0

threads

5

posts

70

credits

Registered member

Rank: 2

credits
70
Published in 2016-2-17 19:27:10 | Show all floors
WereCatf replied at 2016-2-17 19:05
Yeah, it seems there is a bug in the WiringOP - library. I have merged a fix for pull-up/pull-down ...

So, I compiled WiringPi from your git-repo and tried again, and ... It's works prefectly! Thank you very much!

2

threads

19

posts

110

credits

Registered member

Rank: 2

credits
110
Published in 2016-2-18 17:35:58 from mobile | Show all floors
So this fix should make the 433mhz sniffer beable to work because it is also interupt based

2

threads

19

posts

110

credits

Registered member

Rank: 2

credits
110
Published in 2016-2-18 17:45:27 from mobile | Show all floors
to be specific https://github.com/ninjablocks/433Utils this 433 util. It initially didint work because wiringOP didnt handle well on the interrupt

2

threads

144

posts

1066

credits

Gold member

Rank: 6Rank: 6

credits
1066
Published in 2016-2-18 18:05:04 | Show all floors
Does the code rely on digitalRead? There is an issue with digitalRead() when using interrupts on the pin and I am planning to fix it later on today -- if the pin is in mode ALT2, ie. EINT has been enabled, sunxi_digitalRead() fails and digitalRead should instead use the sysfs GPIO-interface to read the value as that seems to return the correct value. I already hacked together something, but I'm not happy with the way I did it. Alas, my boyfriend is nagging me to go and play with him, so I gotta look into it in a few hours..

2

threads

144

posts

1066

credits

Gold member

Rank: 6Rank: 6

credits
1066
Published in 2016-2-18 21:18:50 | Show all floors
Okay, I made a clunky workaround for digitalRead(). I don't yet know how to properly fix it, but the way I did it works for now, at least in my testing.

1

threads

15

posts

103

credits

Registered member

Rank: 2

credits
103
Published in 2016-2-19 22:45:58 | Show all floors

how to use the hardware PWM?
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list