Archives
-
Problem in Stepper Motor code (step angle)
I need to drive a stepper motor that would rotate with a step angle of 7.5 degrees. The code that I wrote has an error even though I am unable to locate anything in the code. Here’s the error:
Error [500] ; . undefined symbols:
_delay (stepper.obj)_digitalWrite (stepper.obj)_digitalRead (stepper.obj)_analogRead (stepper.obj)_pinMode (stepper.obj)The code:
Code:
#include <pic.h>
#define yellow 15 //Q1
#define orange 16 //Q2
#define brown 17 // Q3
#define black 18 // Q4#define CW 33 // SW0 in schematic
#define CCW 34 //SW1 in schematicvoid all_coils_off()
{
digitalWrite(black, 0);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 0);}
void reverse(int i) {
while (1) {
digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0)/4 + 10);
i–;
if (i < 1) break;digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0)/4 + 10);
i–;
if (i < 1) break;digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0)/4 + 10);
i–;
if (i < 1) break;digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0)/4 +10);
i–;
if (i < 1) break;
}}
void forward(int i) {
while (1) {
digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0)/4 +10);
i–;
if (i < 1) break;digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0)/4 +10);
i–;
if (i < 1) break;digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0)/4 +10);
i–;
if (i < 1) break;digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0)/4 +10);
i–;
if (i < 1) break;
}
}void setup()
{
pinMode(CW, RB0);
pinMode(CCW, RB1);// digitalWrite(CW, 1); // pull up on
// digitalWrite(CCW,1); // pull up onpinMode(black, PORTC);
pinMode(brown, PORTC);
pinMode(orange, PORTC);
pinMode(yellow, PORTC);// all coils off
digitalWrite(black, 0);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 0);}
void loop()
{if (!digitalRead(CW))
{forward(200);
all_coils_off();
}if (!digitalRead(CCW))
{reverse(200);
all_coils_off();
}} // end loop
void main ()
{
PORTC=0×00;
PORTB=0xFF;
setup();
loop();
}
Select All
Any help would be appreciated.Related Forum Messages
- Simple project help
- Code for LED vu-meter
- Compound addition to 7 segment
- LED Chasing Lights Progamming
- Else if LEDs
- Restart code and cleanup code with led project.
- Dual 7 segment counter
- Library Error
- Millis! making my head spin
- Can I get some help with my code?
- Arduino speedometer not working for an unknown reason
- Rolling through LED’s with a potentiometer
- I think I’m missing something
- 4×8 Scrolling LED Display (First Arduino Project)
- Seatbelt detection
- Having a little trouble please help
- IF function in Arduino Uno
- Problems with declaring multiple variables
- Switch case problem….
- Loop question
I'm just starting off with my uno and started with a 9 LED's or a breadboard. I am trying to go from pin 13-5 then 5-13 for a bounce back then as the layout is red:yellow:green:red:yellow:green:red:yellow:green i have it doing 13:10:7:12:9:6:11:8:5 so it goes all the reds then yellows then greens. Then I wanted to set a seed to do a random set 10 times before it starts the loop again. Simple stuff I guess. I'll paste the code i have on the bottom but I was wondering how to set up a loop within the main void Loop (). ...First i will introduce myself! I am currently studying avionics in montreal, i know the basics but still have a lot to learn. My main trouble will be the programing, but i think i am coming along well One of my first projects is a vu-meter. i got it working, but i would like to smooth out the edges. I would like to calculate a average over a certain amout of time (a few ms) and then process it to make the leds light up. Here is the code i have for the moment: int val = 0; void setup() { pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); pinMode(10, ...I am very new to using microcontrollers so please excuse any major flaws with the following piece of code. i want 3 analog inputs to add (+=) and the cumulative total (x) to be displayed on a seven segment display. below is where i am so far. i have no idea if this is even close to correct so any assistance would be great. # void loop () if (analogRead(1) lt 20 x += 1; // if only the low sensor is activated +1 is added to var if (analogRead(2) lt 20 x += 2; // middle sensor +2 if (analogRead(3) lt ...Hey guys, So I have a code for a ring of LEDs to make them chase faster and faster. I have the LEDs connected into the PWM pins arranged so that they are symmetrical, which is why the pins switching on and off in my code jump around a little. Here's the code: Code: void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(0, OUTPUT); pinMode(1, OUTPUT); pinMode(2, ...ok, so i've got a 3 x 3 matrix of led's, which at the moment are selected by two pot's, one for x axis, and one for y, but that will change in a moment. the only way i know to make it only turn on one led is like so (code to follow) and I am wondering if there is (i'm sure there is) another, shorter way to do this in the code int g1 = 3; int g2 = 4; int g3 = 5; int b1 = 6; int b2 = 7; int b3 = 8; int r1 = 9; int r2 = ...Hello everyone ! Im a totally noob and beginner in all this, with very old programming skills. So bear with me and hopefully youll learn me some good ways to solve things This is my project: I got five leds and a piezo element, I want a button on the board aswell. The leds are devided into four yellow leds and one red, all yellow leds are on HIGH at first and then starting to go slowly to LOW. When the last yellow led goes out, then the red led takes over with HIGH and then starts blinking after X amount of ...Hi, I've been trying to get two 7 segments to count up to 99 when I have an digital switch input. Currently I have adapted a 0-9 counter to include a second LED 7 segment. I thought if I could delay the second 7 segment turning on, then it would appear as if they were both on at the same time, however at the moment, one turns on and automatically turns off. So instead of getting the number 10, the left LED flashes '1' then the right turns on 0....any suggestions? I'm relatively new to this..... Code: // Seven-segment LED Display // ...I was trying to write a library for a seven segment display when i got the error: "Expected unqualified-id before '.' token". Here is my code: Sketch: Code: #include ltSevenSegment.hgt int a = 2; int b = 3; int c = 4; int d = 5; int e = 6; int f = 7; int g = 8; void setup(){ pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT); pinMode(g, OUTPUT); } void loop(){ SevenSegment.zero(); delay(1000); SevenSegment.one(); delay(1000); SevenSegment.two(); delay(1000); SevenSegment.three(); delay(1000); SevenSegment.four(); delay(1000); SevenSegment.five(); delay(1000); SevenSegment.six(); delay(1000); ...Ive been going through tutorial after tutorial but I cant seem to replicate what ive done with the delay command. Problem is im combining this programming with other loops so I cant use the delay. Heres the code that im trying to get all of the delays switched from milis: Quote int ledPin1 = 13; int ledPin2 = 12; void setup() { pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(ledPin1, HIGH); //START FLSH digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); delay(50); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, HIGH); delay(50); digitalWrite(ledPin1, LOW); ...Hi, I have been trying to get this code for my 7 segment display to run but it will just show a zero.. What am I doing wrong? Quote int A = 15; int B = 14; int C = 4; int D = 3; int E = 2; int F = 16; int G = 17; int Dot = 18; int But = 12; int Num = 0; int Val = 0; void setup() { pinMode(A, OUTPUT); pinMode(B, OUTPUT); pinMode(C, OUTPUT); pinMode(D, OUTPUT); pinMode(E, OUTPUT); pinMode(F, OUTPUT); pinMode(G, OUTPUT); pinMode(Dot, OUTPUT); pinMode(But, INPUT); } void loop() { Num = Val; Val = 1; ...Hi, I'm posting my problem here because that neither me or my brother can find why this program dosen't work. I tried to rewrite it completly many times, use the "else if" instead of all my "if" "else" and I tried other programs on the net. I use a reed switch wich is connected to A0 but I use it as digital input 14 because that my two 7 segments displays use all the digital outputs from 0 to 13. Thank you for your help and sorry for my bad english, i'm 16 y-o and french... btw: this program ...Hello, I've got 5 LED's and a potentiometer. As I roll the pot, I want an LED to come on if the pot's value is within a certain range. All of my grounds are going to a common ground, LED's are in D1-D6, pot is in A0. I'm not getting any compile errors. The current behavior is on boot, LED 1 comes on and when I move the pot, LED 1 stays on and none of the others come on. Any ideas? Code: void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(A0); if(sensorValue lt 205) { ...Hello everyone I think I'm a bit rusty but the following code works except for one part: I cannot return to the original value of count, it is highlighted in the code section. Basically my circuit is a test circuit for a 7 segment display being controlled by a push-button switch. Here is the code: Code: int e = 13; int g = 12; int c = 11; int d = 10; int b = 9; int a = 8; int f = 7; int s; int x; int count; int btt = 2; int ledState = HIGH; ...I have soldered up a 4x8 LED display for my arduino UNO, until I realized that programming would be much harder than I expected. I though that I could just use the bare minimum for arduino programming: Code: void setup() { pinMode (1, OUTPUT); pinMode (2, OUTPUT); pinMode (3, OUTPUT); pinMode (4, OUTPUT); pinMode (5, OUTPUT); pinMode (6, OUTPUT); pinMode (7, OUTPUT); pinMode (8, OUTPUT); pinMode (9, OUTPUT); ...Hey people. I have been working on a system for my science fair that can detect whether a seat belt is fastened. In my prototype the "seat belt" is actually a switch. Fastened = closed, Unfastened = open. The system is made up of two components, a seat belt status checker and a "car". The seat belt status checker lights up a green LED when the switch is closed, and a red one if the switch is open. It is controlled by a 7404 IC. The "car" is a simple LED circuit that should light up only if the ...I'm trying to make an up down counter it counts up each time you press one button and i want it to count down when you press the other. i have it counting up but don't know what to do to get it to count down ? hope someone can help here is my code Code: int a=2; int b=3; int c=4; int d=5; int e=6; int f=7; int g=8; int number=0; int pin9=9; int pin10=10; int pin12=12; int tens=0; int unit=0; int digit=0; int tens1=0; int presentvalue=0; int previousvalue=0; // Pins for A B C D E F G, in sequence const int segs[7] = { 2, 3, 4, 5, 6, 7, 8, }; // Segments that make each number const byte ...Hi I wrote a sketch in Arduino Uno using IF statement as below. Basically it worked only when there are up to 7 no of IF statement. More than that, code did not response (in other word, it did not work). What's wrong with the code? Or how can I improve the code? Thanks for your suggestion. Regards [Edit - moderator - please use the 'code' button when posting code to the forum] Code: Select all void loop() { while (vw_get_message(message, ampmsgLength)) // Non-blocking ...Hello, I am new to this forum so forgive me if there is anything I've left out here. I am trying to run a simple sketch that runs a 4x4x4 LED cube I created using the arduino Mega2560. The cube consists of 16 anode columns and 4 cathode layers similar to: http://www.instructables.com/id/Arduino-4x4x4-LED-Cube/?ALLSTEPS The columns are activated by ditial I/O (22-37) and layers (50-53). I have created a sketch that works fine by declaring each pin to a variable like so: Code: int led22 = 22; int led23 = 23; int led24 = 24; etc... But when I try to run it using this code, It doesn't seem to ...Hello everyone, I'm new to programming world and I need some help for a small school project. I've done a shield that fit on my atmega1280 that reproduce two dices. here's a picture: Each led has a different output pin. For the left dice : 34,32,30 36 38,40,42 I've done a code that should make the left dice show a different number every time that I put my finger on the photoresistor, but it always show 5 and never exit case "5" to go back to default. So here's my code (please don't laught) Code: #include ltLiquidCrystal.hgt LiquidCrystal lcd(8, 9, 4, 5, 6, 7); int res ...Hi, I am building a scoreboard for a foosball table. So basically I have a sensor that every time a ball passes it value changes and the numbers changes on the 7 segment LED. I have created all the functions for the numbers. I just need to know what kind of loop will work here. So if the ball passed by the sensor the number changes. Thanks of all the help This is what I have got so far. Code: int a = 12; int b = 11; int c = 10; int d = 9; int e = 8; int f = 7; int g = 6; int ...
