d13 led is not pin 17! i am confused :^)

The USBDroid provides USB Host functionality for use as an Android peripheral as an Open Android Development Kit board. [Product page]
Post Reply
haveachillday
Posts: 6
Joined: Thu Sep 03, 2015 4:51 am

d13 led is not pin 17! i am confused :^)

Post by haveachillday » Tue Sep 15, 2015 10:06 am

according to the usb droid schematic, pin 17 on the micro controller is the on board led and also digital plug 13. this is confusing me because i tested the blink sketch with pin 17 and it would not flash. however, testing:

dIgitalWrite(13,HIGH); // this lights up the led! strange no?

on top of all that, my custom code here will output to serial console in the IDE (line 39) but wont output to the led on pin 13!

i am very confused by this on board led: how it works with the blink code but not with my code. if there are any wizards out there who can weigh in i seem to have hit a rut in my education. :^(

*EDIT* i think its possible that d13 led is prioritised for SD card clock (SCK) which i am attempting to use in my code. you can see this by looking at the sd card slot on the droid schematic.

Code: Select all

#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>
#include <SD.h>
#include <SPI.h>            //due to a problem with the SD library, research suggest this must be included to access that library.
#define SD_ChipSelectPin 2  //we use this as a sensor to detect if sd card is present.
TMRpcm tmrpcm;              //creates an object pointing at the TMRpcm library for use in this sketch.
bool loopnumber = false;
float final = 0.0;
float initial = 0.0;
float vchange = 0.0;

void setup(){
  Serial.begin(9600); // allows communication with the computer at 9600 bits/S.
  if (!SD.begin(SD_ChipSelectPin)) {
    Serial.println("Can't detect sd card.");  //check the sd card is working.
  }
  else {
    Serial.println("Ready for action!");
  }
  tmrpcm.speakerPin = 28;
  pinMode(13,OUTPUT);    // led d13.
  pinMode(24,INPUT);     //pin A1.
  pinMode(25,INPUT);     //pin A2.
  pinMode(26,INPUT);     //pin A3.
  pinMode(27,INPUT);     //pin A4.
  pinMode(28,OUTPUT);    //pin A5 is the analogue audio output. analogue pins work as digital outputs.
}

void loop() {
  float pinA4 = analogRead(27) * (5.0 / 1023.0);
  if (!loopnumber) {
    initial = pinA4;
    loopnumber = true;  
  }
    final = pinA4;
    vchange = final - initial;
    if (vchange >= 0.3) {
      Serial.println("Button pressed. ");						//LINE 39
      tmrpcm.play("sound1.wav");   
      digitalWrite(13,HIGH);								//NOT LIGHTING UP!
      //delay(5000); //5 second/s before any other high level code is processed.  
    }
  //Serial.println("loopnumber: " + (String)loopnumber + " \ pinA4 = " + (String)pinA4 + " \ vchange = " + (String)vchange);
  initial = final;
}

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: d13 led is not pin 17! i am confused :^)

Post by andrew » Tue Sep 15, 2015 10:53 pm

When you consider the schematic, pin 17 is the physical pin number of the microcontroller itself ... which then goes to the Arduino Uno position D13.

haveachillday
Posts: 6
Joined: Thu Sep 03, 2015 4:51 am

Re: d13 led is not pin 17! i am confused :^)

Post by haveachillday » Tue Sep 15, 2015 11:02 pm

hi john i was under the impression that to program pins on the Arduino IDE, I would have to use the microcontroller pins and not there plug names. am I mistaken? how then would we differentiate between d5 and a5?

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: d13 led is not pin 17! i am confused :^)

Post by andrew » Tue Sep 15, 2015 11:12 pm

When using the Arduino IDE software you use the Arduino's abstract pin numbers.
D5 and A5 are differentiated by the D and A.

Easy reference below ... analogue pins are A0~A5 on the left, digital are D0~D13 on the right. USBDroid also has A6 and A7 between the microcontroller and the uSD card socket.

Image

haveachillday
Posts: 6
Joined: Thu Sep 03, 2015 4:51 am

Re: d13 led is not pin 17! i am confused :^)

Post by haveachillday » Tue Sep 15, 2015 11:18 pm

yeah that infographic clears everything up! thank you sir madam :D

cadmodeling777
Posts: 10
Joined: Fri Apr 21, 2017 8:42 am
Location: MONA TILES COMPOUND, NR. CHHANI CIRCLE, CHHANI ROAD, VADODARA - 390002. GUJARAT, INDIA.
Contact:

Re: d13 led is not pin 17! i am confused :^)

Post by cadmodeling777 » Fri Apr 21, 2017 8:51 am

thanks for this information.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests