Pages: [1]   Go Down
Author Topic: Radio Control of ATtiny13  (Read 1820 times)
0 Members and 1 Guest are viewing this topic.
lost in cyber space
Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have managed to program an ATtiny13 to use as a controller for LED strobe / pulse lights.
I would like to add the ability to turn a LED on and off by using an auxiliary channel on my
JR9303 2.4Ghz remote.
I found this sketch but it produces an error I can't find an explanation for.

Code:
int duration;

void setup()
{
  pinMode(PB2, INPUT);
  pinMode(PB0, OUTPUT);
}

void loop()
{
  duration = pulseIn(PB2, HIGH);
  digitalWrite(PB0, LOW);
  if (duration < 1300)
  {
    digitalWrite(PB0, HIGH);
  }
}


error message:

SwitchRC_AUX.cpp: In function 'void loop()':
SwitchRC_AUX:10: error: 'pulseIn' was not declared in this scope

I can not find PulseIn defined in the ATtiny Data sheet and search returned nothing

I also attempted this code but it only produces a dim or bright LED not the expected on or off
I adjusted the int val entry but got the same result.

Code:
/only switches LED between dim and bright using gear chanel
//with end points set to =/-150 Expected result was PB2 HIGH or LOW
int ledPin = PB2; // LED connected to digital pin PB0
int inPin = PB0;   // pushbutton connected to digital pin PB2
int val = 0;     // variable to store the read value

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin PB0 as output
  pinMode(inPin, INPUT);      // sets the digital pin PB2 as input
}

void loop()
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
}
« Last Edit: August 18, 2012, 10:33:08 pm by gizmoDave » Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Core13 does not implement pulseIn yet.
It is a software function in the core.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

lost in cyber space
Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well that might explain the problem smiley-lol
Any chance I could modify that portion of code from another tiny core or is that function a memory hog?
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am currently working on version 0.16 which will probably include this function.
This version could be released anywhere between now and around a week from now (not really sure).
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

lost in cyber space
Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will watch for a new version release notice.

My current Sketch is using the internal timer, my guess is the pulseIn function will require some type of interrupt to allow the blink portion
of the sketch to continue running the loop.
Logged

Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will watch for a new version release notice.

My current Sketch is using the internal timer, my guess is the pulseIn function will require some type of interrupt to allow the blink portion
of the sketch to continue running the loop.
The pulseIn function does NOT use an interrupt and is a busy wait loop even in the standard core.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

lost in cyber space
Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The pulseIn function does NOT use an interrupt and is a busy wait loop even in the standard core.

I will just have to run a second MCU to handle the added light control function on this project.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   Why not use a 328 or 168 ? You can add a full MFU (Multi Function Unit) capability then, engine sounds, signal lights etc etc ?

   Off the shelf multi function units are incredibly expensive and a little bit daft if you ask me, the tamiya one includes a vibration unit to make your models tail pipes wobble at idle -



The sound is good though !

Duane B

rcarduino.blogspot.com
Logged


Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd bet there is a way to multiplex this in software only but it is really late here and I cannot think of it off hand right now.
Time to go to bed for tonight now..
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Colorado
Online Online
Full Member
***
Karma: 1
Posts: 168
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   Why not use a 328 or 168 ? You can add a full MFU (Multi Function Unit) capability then, engine sounds, signal lights etc etc ?

   Off the shelf multi function units are incredibly expensive and a little bit daft if you ask me, the tamiya one includes a vibration unit to make your models tail pipes wobble at idle -

The sound is good though !

Duane B

rcarduino.blogspot.com

Wow! The sound effects take that RC truck to a whole new level. Excellent!
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not so sure, the sound effects seem out of synch, I wish I could find the video of the vibration unit in action, it wobbles the truck as you rev !

I am just adding an audio amp to my lap timer project but have been thinking about a way to use it to show how much intervention I have in my Yaw Control project, it would be really useful feedback for fine tuning the system and my driving style, imaging progressive skidding sounds when the system needs to intervene -

http://rcarduino.blogspot.com/2012/07/rcarduino-yaw-control-part-2.html

and in action, you will have to imaging sound effects I have a lot of LM386 chips so will have a go at adding them shortly -

https://www.youtube.com/watch?v=TXTCxaamZFU

Duane B

rcarduino.blogspot.com
Logged


lost in cyber space
Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   Why not use a 328 or 168 ? You can add a full MFU (Multi Function Unit) capability then, engine sounds, signal lights etc etc ?

 Duane B

rcarduino.blogspot.com

I have several Ultra Micro (Flying Weight: 1.2 oz (35 g) aircraft that I am outfitting with lights, I have 10 ATtiny13 chips for these small aircraft where added weight is critical.
 I might try a larger chip for other projects where more functions are required and weight is not as big an issue.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   Have you seen this before - http://www.kickstarter.com/projects/digistump/digispark-the-tiny-arduino-enabled-usb-dev-board - someone suggested it on my blog yesterday, it looks very interesting for weight/size sensitive projects like yours.

Duane B

rcarduino.blogspot.com
Logged


Pages: [1]   Go Up
Jump to: