Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - dakong27

Pages: 1
TinyLily / Re: Running hc-sr04 ultrasonic sensor with TinyLily
« on: October 22, 2013, 11:16:29 AM »
Hi Ken,

Here's the code:

Code: [Select]
#define trig 3
#define echo 2
#define led 1

void setup() {
   pinMode(trig, OUTPUT);// attach pin 3 to Trig
   pinMode (echo, INPUT);//attach pin 2 to Echo
   pinMode(led, OUTPUT);//attach pin 1 to LED
  // initialize serial communication:

void loop()
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  digitalWrite(trig, LOW);
  digitalWrite(trig, HIGH);
  digitalWrite(trig, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  duration = pulseIn(echo, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  if(inches < 4){
      digitalWrite(led, HIGH);   // set the LED on
    delay(1000);              // wait for a second             // wait for a second
  } else if (inches>=4){

  Serial.print("in, ");

long microsecondsToInches(long microseconds)
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See:
  return microseconds / 74 / 2;

long microsecondsToCentimeters(long microseconds)
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;

I don't understand what you mean by "reference pin for ADC" or the rest, unfortunately.  On the Arduino platform I understand "plug line A into port A" and read the output in the code.  As a software guy, it works and that's great but the physical mass of even the smallest Arduino form factor does not work for my project.  I know I'm asking annoying noob questions and am loathe to invite a teachable moment, but if you could explain what you mean I would appreciate it, and perhaps through Google many others in my shoes would appreciate it too.

TinyLily / Re: Running hc-sr04 ultrasonic sensor with TinyLily
« on: October 20, 2013, 12:04:02 AM »
Thanks, Ken.  The 5V-jumpered USB adapter arrived this afternoon so I hooked it up to the TinyLily and tried the sensor (on the TinyLily, the sensor's trig pin is connected to the 3 pin, the echo pin to the TinyLily 2 pin.).  Turning on the Serial Monitor, it's still returning gobblety-gook.  I know the sensor, the circuit, and the sketch are fine because swapping out the TinyLily for an Arduino Uno works, returning normal readings like "3 in...8 in...14 in."  I've successfully tried the sensor and circuit with an Arduino Micro as well.   

I have gotten the Blink sketch to work with the TinyLily on a breadboard, so I know the TinyLily is fine.  Do I need to take additional steps to get sensors working with TinyLily? 

TinyLily / Re: Running hc-sr04 ultrasonic sensor with TinyLily
« on: October 08, 2013, 01:38:41 PM »
An update--I saw in the specs for the TinyLily Mini USB Adapter that there is a "resistor jumper option" to toggle output on the TinyLily between 5V and 3.3V, and that the default is 3.3V.  It sounds like the solution to my issue.

However, looking at the TinyLily Mini USB Adapter there doesn't appear to be a jumper like you'd have in an old desktop computer.  I looked at the schematic here:, which indicates a jumper but it's not clear what it looks like on the board or how to switch it.

Does anyone know how to do this?

TinyLily / Running hc-sr04 ultrasonic sensor with TinyLily
« on: October 08, 2013, 09:49:51 AM »
I'm working on an autonomous helium/hydrogen-filled toy zeppelin for my kids' room that uses a TinyLily with an HC-SR04 ultrasonic proximity sensor to detect when it's approaching a wall and then turn until it can fly some more, flashing LEDs and producing sound effects like "Ahoy there!" all the while.

Weight is a concern, which is why I'm trying to do it with the TinyLily so the envelope of the zeppelin can remain small enough to provide sufficient lift but still maneuver within their room.

I have gotten the sensor to work with an Arduino Uno, but not with the TinyLily.  The voltmeter says the Uno's supplying 5V but the TinyLily's only supplying 3.3, below the 4.5 minimum the sensor needs.  Here are the specs for the sensor:

            Parameter    Min    Typ.    Max    Unit
Operating Voltage   4.50    5.0     5.5     V
Quiescent Current   1.5      2        2.5     mA
Working Current      10       15      20       mA

I am a beginner with electronics, and am stuck at this point.  What is the best way to get the sensor to work with the TinyLily?  Is there a way to bump up the voltage so the sensor will work? 

Thanks in advance for any pointers you guys might have.

TinyLily / Re: Broken TinyLily USB Shield? (SOLVED)
« on: October 04, 2013, 01:37:01 PM »
I'll mark this one SOLVED.  The image on the card "Getting Started with your TinyLily Mini" was pretty dark and I misread it.  It looked like the processor was supposed to go chip side up.  Flipped it over and problem solved.

Noob mistake, but thought I'd post the outcome here to spare future noobs the same embarrassment.

TinyLily / Broken TinyLily USB Shield?
« on: October 03, 2013, 05:47:08 PM »
I received the TinyLily Starter Kit today and tried to plug it into my laptop via micro-USB and upload Arduino's Bare Minimum Sketch.  I got an error saying "avrdude: stk500_recv(): programmer is not responding."

I tried both Mini Processor Boards that came in the kit with the same result.  Could the TinyLily USB Shield be broken?  How can I tell?

I'm running Ubuntu 12.04, which googling says has the FTDI drivers already bundled with the Arduino IDE, and the IDE's Tools -> Serial Port lists /dev/ttyUSB0, so I think the driver's not the problem.

Anyway, appreciate any advice you guys might have.

Pages: 1
SMF spam blocked by CleanTalk