View: 6031|Reply: 1

LCD 1602 + Orange Pi Zero GPIO?

[Copy link]

1

threads

1

posts

5

credits

Novice

Rank: 1

credits
5
Published in 2017-8-25 15:55:01 | Show all floors |Read mode
Edited by kiwisaurio at 2017-8-25 17:54

Hey guys, I'm new on this kind of things. I recently bought an Orange Pi Zero and i'm kinda lost with everything. I found a picture of its GPIO but I can't solve what does the letters mean on every pinout.
The point is that I wanted to place a 1602 LCD on it, and make it to show me the temperature and the status of the Orange Pi (like, is it's online, working on its process, w/e) but I dont know how to do it.
Do you guys know anything about this and could you help me? Thank you.

Here is the GPIO picture in case you don't want to look for it: https://oshlab.com/orange-pi-zero-pinout/
Forgot to say what OS I'm using. I'm using DietPi and I saw that it has a GPIO library, I'll update this post later.

10

threads

218

posts

2040

credits

Gold member

Rank: 6Rank: 6

credits
2040
Published in 2017-8-26 07:37:07 | Show all floors


  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <wiringPi.h>
  5. #include <lcd.h>

  6. /*
  7. cc -o lcd lcd.c -lwiringPi -lwiringPiDev

  8. lcd
  9. lcd line1 line2

  10. 1602LCD    PI
  11. VSS    --- 5V
  12. VDD    --- Gnd
  13. V0     --- Volume
  14. RS     --- Pin#16
  15. RW     --- Gnd
  16. E      --- Pin#18
  17. D0
  18. D1
  19. D2
  20. D3
  21. D4     --- Pin#11
  22. D5     --- Pin#12
  23. D6     --- Pin#13
  24. D7     --- Pin#15

  25. */

  26. #define DEBUG   0

  27. int main(int argc, char **argv) {
  28.     int fd_lcd;
  29.     int stlen;
  30.     int i;
  31.     int line;
  32.     char string1[17];
  33.     char string2[17];

  34.     if(wiringPiSetup() == -1) {
  35.         printf("Setup Fail\n");
  36.         exit(1);
  37.     }
  38.     fd_lcd = lcdInit(2,16,4,4,5,0,1,2,3,0,0,0,0);

  39. if(DEBUG)printf("argc=%d\n",argc);
  40.     memset(string1,0,sizeof(string1));
  41.     memset(string2,0,sizeof(string1));
  42.     if(argc == 1) {
  43.       lcdClear(fd_lcd);
  44.     } else if (argc == 2) {
  45.     } else if (argc == 3) {
  46.       stlen=strlen(argv[1]);
  47. if(DEBUG)printf("stlen=%d\n",stlen);
  48.       if (stlen < 17) {
  49.         strcpy(string1,argv[1]);
  50.       } else {
  51.         strncpy(string1,argv[1],16);
  52.       }
  53.       stlen=strlen(argv[2]);
  54. if(DEBUG)printf("stlen=%d\n",stlen);
  55.       if (stlen < 17) {
  56.         strcpy(string2,argv[2]);
  57.       } else {
  58.         strncpy(string2,argv[2],16);
  59.       }
  60.       lcdPosition(fd_lcd,0,0);
  61.       lcdPuts(fd_lcd,string1);
  62.       lcdPosition(fd_lcd,0,1);
  63.       lcdPuts(fd_lcd,string2);
  64.     }
  65. }
Copy code



Clear LCD
$sudo ./lcd

Show LCD
$sudo ./lcd Line1 Lne2

You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list