Radio Control of ATtiny13

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.

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.

/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
}

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

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

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).

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.

gizmoDave:
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.

smeezekitty:
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.

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

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..

DuaneB:
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!

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 -

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 -

Duane B

rcarduino.blogspot.com

DuaneB:
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.

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