Jump to content


Photo

How to access GPIO with Android pcDuino ?


  • Please log in to reply
4 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 03 December 2014 - 02:23 AM

I installed Android on pcDuino. 

How can I access a GPIO ?

GPIO access Android API library ?


  • carpinteyrolkh likes this

#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 03 December 2014 - 02:23 AM

you can do it this way:

		Button B = (Button)findViewById(R.id.button1);
		B.setOnClickListener(new View.OnClickListener(){

				public void onClick(View p1)
				{
					
					try
					{
						//GPIO_PIN_NUM (0-19) MODE(0 for input, 1 for output) 		
						Process su_mode = Runtime.getRuntime().exec("./system/sample/core/pin_mode 2 1");
						// GPIO_PIN_NUM (0-19) GPIO_LEVEL(0/1)"
						Process su_set = Runtime.getRuntime().exec("./system/sample/core/gpio_set 2 1");
					}
					catch (IOException e)
					{}
				}

			
		});
		
		Button B1 = (Button)findViewById(R.id.Button01);
		B1.setOnClickListener(new View.OnClickListener(){

				public void onClick(View p1)
				{
					
					try
					{
						//GPIO_PIN_NUM (0-19) MODE(0 for input, 1 for output) 		
						Process su_mode = Runtime.getRuntime().exec("./system/sample/core/pin_mode 2 1");
						// GPIO_PIN_NUM (0-19) GPIO_LEVEL(0/1)"
						Process su_set = Runtime.getRuntime().exec("./system/sample/core/gpio_set 2 0");
					}
					catch (IOException e)
					{}
				}

			
		});


#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 03 December 2014 - 02:23 AM

Thank you so much, Six1.



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 03 December 2014 - 02:23 AM

What about accessing the UART interface or I2C?
Any example?



#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 03 December 2014 - 02:23 AM

If you flash pcDuino with latest Android image, there are built in samples under /home/






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users