문제

How do you turn the power on and off in software for the "Switched" side of the grove connectors on a Sodaq Moja?

I know its a matter of "turning off the ground". What is an example of code that does that?

도움이 되었습니까?

해결책

I figured out how to do it. While it is really not documented there is an accidental hint under section "2. Programming the SODAQ board" at http://www.sodaq.net/#!getting-started/c21ma.

"Pin 6 is normally used for switching power to the Switched row of Grove connectors, but for now we just use it because it has an LED too."

The digital pin 6 powers both the led and the actual grove connectors as well. Here is some sample code.

void setup()
{
    pinMode(6, OUTPUT);
    Serial.begin(9600);
}

void loop()
{
    digitalWrite(6, HIGH); // Turns on both the LED and the power
    delay(400);
    int value = analogRead(A0); // read your analog sensor that needs power
    digitalWrite(6, LOW); // turns off the power
    Serial.println(value);
    delay(1000);
 }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top