Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
Author: linga51

GPIO library - WiringPi

[Copy link]

0

Threads

6

Posts

114

Credits

Registered member

Rank: 2

Credits
114
Post time 2016-2-17 15:52:37 From the mobile phone | Show all posts
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

871

Credits

Senior member

Rank: 4

Credits
871
Post time 2016-2-17 17:21:41 | Show all posts
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
Post time 2016-2-17 17:26:31 | Show all posts
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 the Code
  1. pinMode(6, OUTPUT);
Copy the Code
It's a LED
  1. pinMode(7, OUTPUT);
  2.   pinMode(8, INPUT);
Copy the 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

871

Credits

Senior member

Rank: 4

Credits
871
Post time 2016-2-17 19:05:38 | Show all posts
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
Post time 2016-2-17 19:27:10 | Show all posts
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
Post time 2016-2-18 17:35:58 From the mobile phone | Show all posts
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
Post time 2016-2-18 17:45:27 From the mobile phone | Show all posts
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

871

Credits

Senior member

Rank: 4

Credits
871
Post time 2016-2-18 18:05:04 | Show all posts
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

871

Credits

Senior member

Rank: 4

Credits
871
Post time 2016-2-18 21:18:50 | Show all posts
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
Post time 2016-2-19 22:45:58 | Show all posts

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

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-12-15 16:22 GMT+8 , Processed in 0.033052 second(s), 20 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list