0

programming SW-18010p with GEMMA by Arduino
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

programming SW-18010p with GEMMA by Arduino

by Hajir on Wed Mar 17, 2021 12:18 pm

Hi,

i have tried to program SW-18010p with Gemma M0 but i have not get result.

the code is when i shake SW-18010p, the led D1 should turn on, otherwise it will turn off.

but the result is the led is turn on, it does not respond to the movement of SW-18010p.

i need your help as soon as possible.

Code: Select all | TOGGLE FULL SIZE
const int LED = 1; //Buzzer connected to pin 8 of Arduino uno / mega
int sensor;           //Variable to store analog value (0-1023)


void setup()
{
 
  pinMode(LED, OUTPUT);
}

void loop()
{
  sensor = analogRead(1);
  if (sensor<1022){
    digitalWrite(LED, HIGH);
  }
 
  else{
     digitalWrite(LED, LOW);

  }
 
 
  delay(100); //Small delay
}



i need help as soon as possible.

kind regards
hajer

Hajir
 
Posts: 9
Joined: Sun Dec 20, 2020 12:22 pm

Re: programming SW-18010p with GEMMA by Arduino

by dastels on Wed Mar 17, 2021 12:51 pm

To start with, you're reading the sensor and writing the LED on the same pin.

Dave

dastels
 
Posts: 6872
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.