วันพฤหัสบดีที่ 20 ตุลาคม พ.ศ. 2554

Android Volt Meter with IOIO Board






Android Volt Meter with IOIO Board
We can use Android phone as Digital Volt meter with IOIO Board.

We edit IOIO Sample App Source code. It has Analog to digital input code.
Testing on Samsung Spica i5700 ( Update to 2.2 )

มาทำ โวลต์มิเตอร์ ด้วย Android + IOIO Board ( โยโย่ บอร์ด )
ทดสอบกับโทรศัพท์มือถือ samsung spica i5700 ( up ROM เป็น 2.2 แล้วใช้ได้ )


Original Code
public void loop() throws ConnectionLostException {
      try {
            final float reading = input_.read();
            setText(Float.toString(reading));
           

pwmOutput_.setPulseWidth(1000 + seekBar_.getProgress());
            led_.write(!toggleButton_.isChecked());
            sleep(10);
            } catch (InterruptedException e) {
                  ioio_.disconnect();
            } catch (ConnectionLostException e) {
                  enableUi(false);
                  throw e;
            }
      }
Edit Code
public void loop() throws ConnectionLostException {
      try {
            final float reading = input_.getVoltage();                 
            float div4 = 4;
            setText(Float.toString(reading*div4));
           
                                   
            pwmOutput_.setPulseWidth(1000 + seekBar_.getProgress());
                  led_.write(!toggleButton_.isChecked());
                  sleep(10);
            } catch (InterruptedException e) {
                  ioio_.disconnect();
            } catch (ConnectionLostException e) {
                  enableUi(false);
                  throw e;
            }
      }

We change input   final float reading = input_.read();
setText(Float.toString(reading));
to                          final float reading = input_.getVoltage();           
                  float div4 = 4;
                  setText(Float.toString(reading*div4));

If you not use float div4 = 4; and setText(Float.toString(reading*div4));
You can read voltage only 3.3 V.
Then use div4 = 3.3 x 4 =  13.2 V. ( But need  voltage divider circuit )
Voltage Divider Circuit
V out = Vin/4  Then V out  connect to Pin 40 IOIO Board.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น