need an Arduino code from a tutorial that posted in adafruit

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mohammedkw
 
Posts: 4
Joined: Thu Sep 15, 2016 3:57 pm

need an Arduino code from a tutorial that posted in adafruit

Post by mohammedkw »

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!

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

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

Post by adafruit_support_jarek »

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

digitalRead( 9 );
In order for the sensor to work, you have to first turn on the LED:

Code: Select all

digitalWrite( 13, HIGH );
A quick sample sketch to see if everything works:

Code: Select all

#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 );
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”