Micro Joysticks In Place Of Dial On Servo Testers

Thread Starter

DragonTheta

Joined Feb 6, 2022
89
It's misleading. There are a huge number of third-party boards that are compatible. Arduino keeps a list of them here. The URL after the titles are the files that contain the information the IDE needs to install the support files for the board. They show up in the list of boards to select. Below is the Digistump section from the list. A note about the Digispark: you need a driver if you are using Windows but it gets installed during the IDE update; also, unlike most boards, you plug in the board to be programmed after the program has compiled. It prompts you and gives you 60 seconds to do it.

One more thing, this is the preferences dialog where you enter additional board URLs. You can have as many as you like.

So what do I do in order to get the DigiSpark working? I want to put the code onto it... Do I add the URL for the DigiSpark into the Arduino web editor?
 

Thread Starter

DragonTheta

Joined Feb 6, 2022
89
Thanks

I put in the code and it said
exit status 1
'D0' was not declared in this scope

Here's the code KeithWalker gave

// Program an ATTINY85 to set position of servo by position of potentiometer.
// Pot connected to pin A1, servo connected to pin D0

int val;

void setup()
{
pinMode(D0, OUTPUT); //Defines D0 as output for servo
digitalWrite (D0, LOW); // Sets servo output low
}
void loop()
{
val = analogRead(A1); // Reads position of potentiometer
val = map(val, 0, 1023, 1000, 2000); //Scales the input range to pulse length values (uS)

digitalWrite (D0, HIGH); // Generates a positive output pulse
delayMicroseconds (val);
digitalWrite (D0, LOW);
delay (16); // Sets the frame rate
}
 

Ya’akov

Joined Jan 27, 2019
10,356
Thanks

I put in the code and it said
exit status 1
'D0' was not declared in this scope

Here's the code KeithWalker gave

// Program an ATTINY85 to set position of servo by position of potentiometer.
// Pot connected to pin A1, servo connected to pin D0

int val;

void setup()
{
pinMode(D0, OUTPUT); //Defines D0 as output for servo
digitalWrite (D0, LOW); // Sets servo output low
}
void loop()
{
val = analogRead(A1); // Reads position of potentiometer
val = map(val, 0, 1023, 1000, 2000); //Scales the input range to pulse length values (uS)

digitalWrite (D0, HIGH); // Generates a positive output pulse
delayMicroseconds (val);
digitalWrite (D0, LOW);
delay (16); // Sets the frame rate
}
That's because the code he gave you is for the ATTINY85 not the ATTINY85 on a Digispark.

The program has to be adapted to match the pins on the board. Here is a diagram:

1644804628805.png
​
The numbers are the literal pin numbers but you can use the PBn numbers. Use PB1 in instead of D0 and PB2 instead of A1. Connect to the corresponding pins, they are marked on the bottom of the board.
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,237
Thanks

I put in the code and it said
exit status 1
'D0' was not declared in this scope

Here's the code KeithWalker gave

// Program an ATTINY85 to set position of servo by position of potentiometer.
// Pot connected to pin A1, servo connected to pin D0

int val;

void setup()
{
pinMode(D0, OUTPUT); //Defines D0 as output for servo
digitalWrite (D0, LOW); // Sets servo output low
}
void loop()
{
val = analogRead(A1); // Reads position of potentiometer
val = map(val, 0, 1023, 1000, 2000); //Scales the input range to pulse length values (uS)

digitalWrite (D0, HIGH); // Generates a positive output pulse
delayMicroseconds (val);
digitalWrite (D0, LOW);
delay (16); // Sets the frame rate
}
So it appears that the definition of the Digispark development board does not include D0. D0 is a reserved word. It IS defined for the Arduino boards.

That doesn’t mean that you can’t use the Digispark. It DOES mean that the program must explicitly define D0 as the pin on the ATTiny85 that’s used for that function.
 

djsfantasi

Joined Apr 11, 2010
9,237
That's because the code he gave you is for the ATTINY85 not the ATTINY85 on a Digispark.

The program has to be adapted to match the pins on the board. Here is a diagram:

The numbers are the literal pin numbers but you can use the PBn numbers. Use PB1 in instead of D0 and PB2 instead of A1. Connect to the corresponding pins, they are marked on the bottom of the board.

You'd will al
Missed it by this much.
 

Thread Starter

DragonTheta

Joined Feb 6, 2022
89
Thank you

I changed it in the code and hit upload. It told me to plug in the device and when I did, the computer kept giving the plug in and unplug noises over and over and Arduino never recognized the DigiSpark.
 
Last edited:

Ya’akov

Joined Jan 27, 2019
10,356
Thank you

I don't get it. What does it mean the arrow thing that you wrote

And I see the 5V pin...The middle one is labeled PIN. Is the middle one the signal output, and the unlabeled pin is the ground?
The dotted arrow is the axis of motion that will be measure. The stick moving within rather than against, the white plastic slot.

The unused pin is unused. The potentiometer is a variable resistor, it will be varying the voltage that appears on the analog pin. 5V in on the first pin, varying voltage out on the middle pin. The third pin is the other end of the resistor inside and we don't care about it.

Look here: https://fddrsn.net/pcomp/examples/potentiometers.html
 

Thread Starter

DragonTheta

Joined Feb 6, 2022
89
The dotted arrow is the axis of motion that will be measure. The stick moving within rather than against, the white plastic slot.

The unused pin is unused. The potentiometer is a variable resistor, it will be varying the voltage that appears on the analog pin. 5V in on the first pin, varying voltage out on the middle pin. The third pin is the other end of the resistor inside and we don't care about it.

Look here: https://fddrsn.net/pcomp/examples/potentiometers.html
Thanks

It shows in the wiring diagram on page 4 the ground on the ESCs and the ground on the DigiSpark both being connected to ground on the joystick
 
Top