0

need an Arduino code from a tutorial that posted in adafruit
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

need an Arduino code from a tutorial that posted in adafruit

by mohammedkw on Wed Nov 16, 2016 10:43 am

Hi everyone,

I'm a beginner in the kind of programming, and I have an assignment from my school to do simple project!

I chose an experiment that already existed in this website, so I can get started quickly.

Here's the brushes (Reflective IR sensor) link from Adafruit that I bought: https://www.adafruit.com/products/2349

And I have this Feather, also from Adafruit: https://www.adafruit.com/products/2821

I want to apply the IR sensor for the LED( same the experiment in the IR sensor webpage); however, I couldn't find an appropriate Software code for that!



ANY help will be appreciated!

mohammedkw
 
Posts: 4
Joined: Thu Sep 15, 2016 3:57 pm

Re: need an Arduino code from a tutorial that posted in adaf

by adafruit_support_jarek on Wed Nov 16, 2016 11:06 am

Hi there! As long as you wire up the sensor the exact same way as in the picture under Technical Details https://www.adafruit.com/products/2349 , you should be able to read the sensor by using the function
Code: Select all | TOGGLE FULL SIZE
digitalRead( 9 );

In order for the sensor to work, you have to first turn on the LED:
Code: Select all | TOGGLE FULL SIZE
digitalWrite( 13, HIGH );


A quick sample sketch to see if everything works:
Code: Select all | TOGGLE FULL SIZE
#define LED_PIN 13
#define SENSOR_PIN 9

void setup() {
  Serial.begin( 9600 );
  pinMode( LED_PIN, OUTPUT );
  pinMode( SENSOR_PIN, INPUT_PULLUP );
  digitalWrite( LED_PIN, HIGH );
}

void loop() {
  byte state = digitalRead( SENSOR_PIN );
  Serial.println( state );
}

adafruit_support_jarek
 
Posts: 324
Joined: Tue Nov 08, 2016 11:48 am

Please be positive and constructive with your questions and comments.