Jump to content
Sign in to follow this  
jim

How to access GPIO with Android pcDuino ?

Recommended Posts

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)
					{}
				}

			
		});

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×