Hi all.
So this is like my 5th time using arduino for a project and Im already having trouble with the sketch.
Im following a tutorial on youtube on how to build a motorized longboard and in the tutorial, it is shown how to modify a wii nunchuck and turn that into a remote for the longboard.
To make the nunchuck work with the longboard, you need to program a ATtiny 45 boards which are here: GitHub - damellis/attiny: ATtiny microcontroller support for the Arduino IDE. Then you would have to paste the "attiny-master" folder into the hardware folder of the arduino like shown in the tutorial. But in doing that, the boards dont show up after I launch the program. So I had to copy the boards into the folders themselves.
As for the sketch, it is provided from the tutorial but when I go to verify with the board selected, there seems to be a " 'Software Servo' does not have a name type" error. I need some assistance an if i have seem to have miss-clarified something just ask 
Also the tutorial im following is : Make your own Electric Motorized Longboard (Part 3) - the wiring & remote control - YouTube which starts at 7:40
That error refers that it cannot find the library. First thing is to remove "-master" from the folder name.
Then post your code in code tags and then paste errors in another set of code tags.
To add Dan Mellis' ATtiny cores, you don't have to add it to 'libraries' and mess around.
Open the Arduino IDE, then click on >File >Preferences.
Next, add this line to "Additional Boards Manager URLs":-
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
Next, click on >Tools >Board >Boards Manager
Scroll down to the ATtiny, click "More Info", then "Install".
If there's a problem after either step, close then re-open the IDE and continue. (I forget which step might require this.)
The chip can then be selected under >Tools >Board, just like any other board. Various chip and oscillator options are available.
Regarding the "SoftwareServo" problem, show us your complete code as suggested by codlink.
You did add this near the top of your sketch, I assume:-
#include <SoftwareServo.h>
Your error indicates that you forgot to include the library.
I also assume that you have actually installed this library.
A link to the library would also help.
Thanks for the help for installing the boards Steve.
Here is the sketch:
#include <SoftwareServo.h>
int potentiometer=A1;
int button1=3;
int button2=4;
int potval;
int curval;
SoftwareServo ESC;
void setup() {
pinMode(potentiometer, INPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
ESC.attach(1);
curval=0;
ESC.setMinimumPulse(800);
ESC.setMaximumPulse(2000);
}
void loop() {
while (digitalRead(button1)==HIGH){
potval=analogRead(potentiometer);
potval=map(potval,0,1023,0,180);
while(curval<potval){
potval=analogRead(potentiometer);
potval=map(potval,0,1023,0,180);
curval=curval+1;
ESC.write(curval);
SoftwareServo::refresh();
delay(50);
while(digitalRead(button2)==HIGH){
ESC.write(curval);
SoftwareServo::refresh();}}
while(curval>potval){
potval=analogRead(potentiometer);
potval=map(potval,0,1023,0,180);
curval=curval-1;
ESC.write(curval);
SoftwareServo::refresh();
delay(50);
while(digitalRead(button2)==HIGH){
ESC.write(curval);
SoftwareServo::refresh();}}
ESC.write(curval);
SoftwareServo::refresh();}
potval=0;
while(curval>potval){
curval=curval-1;
ESC.write(curval);
SoftwareServo::refresh();
delay(50);}
ESC.write(curval);
SoftwareServo::refresh();}
I forgot to state that it was already included in the library but I just dont know what is wrong when I go to verify it.
Arduino: 1.6.7 (Windows 7), Board: "ATtiny, ATtiny85, 1 MHz (internal)"
C:\Users\homeuser\Desktop\AttinySketch\AttinySketch.ino:1:28: fatal error: SoftwareServo.h: No such file or directory
#include <SoftwareServo.h>
^
compilation terminated.
exit status 1
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
This is the error message if it helps.
That's a different error message to the original one. Your original error was:-
'Software Servo' does not name a type
, which you would have received for not including the header file.
This new error message:-
fatal error: SoftwareServo.h: No such file or directory
, indicates that you don't have the library installed, or not correctly at least.
I covered both of these possibilities in my last reply:-
Your error indicates that you forgot to include the library.
I also assume that you have actually installed this library.
So, have you installed the "SoftwareServo" library?
Im guessing I havent, and I wouldnt have a clue as to what to install regarding the "SoftwareServo" library. What would it be?
I had a the "SoftwareServo" error when i was running 1.0.5r-2. Then when you told me a way to install the boards, i didnt see some of the tabs i was looking for in my version of arduino so I update it. And now i get the error message that I have pasted above. Sorry for the misunderstanding.
nggtristan:
Im guessing I havent, and I wouldnt have a clue as to what to install regarding the "SoftwareServo" library. What would it be?
If you're lucky, it's the one described on this page:-
SoftwareServo Library
(You could have tried Googling "SoftwareServo Library". That's how I found it.)
Edit: I just had a look at that library. It does appear to be the one you want.
Would my code have to be amended if I told you that my project actually has no servo in it?
nggtristan:
Would my code have to be amended if I told you that my project actually has no servo in it?
You're kidding. Why would you be using code to drive a servo when you don't want to drive a servo?
The whole purpose of the code you posted is to read a pot and position or set the speed of a servo accordingly. It doesn't do anything else.
(I didn't watch that video. You need to post any info here, not just provide links to other sites.)
So what type of motor do you have for your longboard?
Edit: I now see that actually, although you say the important stuff starts at 7:40 in the video you linked, it's actually part three of a series.
Start from the beginning - describe all of your hardware.
I didnt write the code. Im just simply following the tutorial and the sketch that has been provided
If you watch this segment of the video at 7:40 Make your own Electric Motorized Longboard (Part 3) - the wiring & remote control - YouTube All im trying to build and code for is the wii nunchuck. The sketch is available to download in the description on instructables
EDIT: Its a 400KW Outrunner brushless motor with a 80A esc
You didn't say anything about an 'Instructables' tutorial until right now. We aren't mind-readers.
And I have no intention of reading through some 'instructable' and watching a series of videos.
Again, describe your hardware in full, and provide a schematic diagram please.
Links to anything relevant like the motor controller, (I now assume you're using one), and the exact motor that you're using would also help. And what type/size of battery are you using?
This thread obviously isn't simply about "Programming the ATtiny 45", as the title suggests.
Okay so here is the breakdown of the project. I am building a motorized longboard with a diy wii nunchuck as a remote controller for the longboard.
So if i was to split the build into 2 parts. Part 1 is the longboard build along with the circuitry that belongs with that and part is 2 the building of the wii nunchuck and programming.
Part 1: The main parts to the longboard build and its circuits are
1x 400kV 1560W brushless outrunner motor
2x 22.2V 5000mAh LiPo Battery
1x 70A ESC
Part 2: The main parts to the wii nunchuck remote build and its circuits are :
1x STX882 Transmitter, SRX882 Receiver
1x NE5534 Chip
1x ATtiny45
1x 380mAh 3.7V LiPo Battery
1x Charging/Protection Circuit
3x 10K resistor
1x Micro USB Board
I hope that clarifies something, sorry for the misunderstanding
EDIT: I have provided some schematics and other build photos. The photo with the chip socket and the receiver, is where the ATtiny chip goes in after its programmed(which would be skem 1)
It would be nice to see two full schematics - one for the transmit end and one for the receive/longboard end.
Also a link to the ESC documentation would help.
And without full schematics, I have no idea where the op-amp fits into the scheme of things.
Anyway, going from what I've seen you need the servo library to control the ESC which in turn controls the brushless motor. (I've personally never used a servo-pulse-controlled motor driver.)
We're forced to assume that everything in the instructions will work if it's connected correctly, so next you need to download that library and install it, then try to compile the provided code.
Then take it from there.
I must say that I have absolutely no faith in 'Instructables', they're often a case of the blind leading the blind, so let's hope everything works. Fingers crossed.
This is the only schematic I could find and thats pretty much thats all provided.
Ive downloaded the servo library but to be honest, i have no idea where to put the files to or install it
nggtristan:
This is the only schematic I could find and thats pretty much thats all provided.
Without a full schematic of each half of the project, how are you figuring out how to connect things?
I hope the 'Instructable' and the video series explain it very clearly. The first step in any electronic design is a schematic diagram.
Ive downloaded the servo library but to be honest, i have no idea where to put the files to or install it.
Haven't you ever installed a library before? It's a pity, because it's a very old library, and needs to be modified before it will compile. (This is turning into a far bigger operation than I expected when I posted my first reply.)
I just did what's necessary and the sketch compiles fine for me, with ATtiny45, 8MHz internal oscillator.
OK, I'll go through things one step at a time.
-
Unzip the library in a place you can easily access. (I did it on my desktop.)
-
Open the outer folder, then the inner one named "SoftwareServo", and open the "SoftwareServo.h" file.
-
Near the top, you'll see a line:-
#include <WProgram.h>
Comment this line out,
then add the following line:-
#include <Arduino.h>
Save the file, then go up a folder layer, to the inner "SoftwareServo" folder.
-
Copy that folder, (not the outer one), then browse to your "Sketchbook" folder and in it you'll find a folder titled "libraries". Paste the "SoftwareServo" folder into the "libraries" folder.
-
Close the Arduino IDE, then re-open it, open the sketch and try to compile it. (Should compile without errors.)
(Be sure to select "ATtiny45, 8MHz internal oscillator" under >Tools.)
Let me know how you go.
Edit: Noticeably, that code makes no provision for wireless control using a transmitter/receiver. It just directly reads a pot and two buttons to control the motor.
I guess there's another more advanced sketch that will do everything, using the Wii Nunchuck. (I'm not familiar with Wii or Nunchuck. The latest game console I've used is a PS2.
)
I just finished an last year of highschool last year and was doing electronics and they didnt even teach us how to read a schematic of a circuit, so my alternative was more so pausing the video and look at the wiring through there.
No i actually have installed a library before. Like i said haha its like my 5th time using arduino. Its not my knack if you can tell haha
Where would the "sketchbook" folder be located?
Im looking at this directory C:\Program Files (x86)\Arduino if thats the correct place?
nggtristan:
I just finished an last year of highschool last year and was doing electronics and they didnt even teach us how to read a schematic of a circuit, so my alternative was more so pausing the video and look at the wiring through there.
No i actually have installed a library before. Like i said haha its like my 5th time using arduino. Its not my knack if you can tell haha
Where would the "sketchbook" folder be located?
Im looking at this directory C:\Program Files (x86)\Arduino if thats the correct place?
Don't put it in the "\Arduino\libraries" folder. That's for libraries that are supplied with the IDE.
In the IDE, if you click >File >Preferences, you'll see the location of the "Sketchbook" folder. The correct (3rd party) libraries folder is inside the "Sketchbook" folder.
Thank you for the clarification and sorry for confusing you this whole time. Cheers heaps
nggtristan:
I wasnt able to find the "sketchbook" folder
Isn't it listed in the "Preferences" dialog?
Did you click on >File >Preferences?
What version of the IDE are you using?
When you write sketches, the "Sketchbook" is the default "save" location.
If you click on "Save As", (but don't actually save the sketch), you'll see a "Save sketch folder as..." dialog.
If you go up one folder level, you'll see where it is stored.
(Take a look in "My Documents".)
You quite clearly need to familiarise yourself with Arduino and the IDE.
If all else fails, do a system search for a folder named "Sketchbook".
This just shouldn't be this hard. 