Go Down

Topic: help micro elevator code (Read 3 times) previous topic - next topic

tuxduino

Quote
i suck so much


I think you just need to take some time to review the C syntax and the Arduino API (arduino.cc => Reference).

About the hall sensor... You need to know when the elevator reached a particular floor. Isn't the floor switch enough ?

PeterH


Code: [Select]

  Floor++; 
  Floor=Floor+2;
   Floor=Floor+3;



I doubt this will end up with the correct value in Floor. I haven't reviewed the whole sketch, but I'd expect to see Floor assigned to the value corresponding to the floor it has just reached (Floor = 3; etc) or incremented / decremented by one each time is passes a floor ( Floor++; Floor--; ).
I only provide help via the forum - please do not contact me for private consultancy.

copachino



Code: [Select]

  Floor++; 
  Floor=Floor+2;
   Floor=Floor+3;



I doubt this will end up with the correct value in Floor. I haven't reviewed the whole sketch, but I'd expect to see Floor assigned to the value corresponding to the floor it has just reached (Floor = 3; etc) or incremented / decremented by one each time is passes a floor ( Floor++; Floor--; ).


the problem comes when the elvator moves more than one floor but i dont think thats a problem, still i can  just use Floor= 2 directly instead or just increments o decrements

copachino

About the hall sensor... You need to know when the elevator reached a particular floor. Isn't the floor switch enough ?
[/quote]

the whole idea of the hall sensor, its no count steps, i dont want to counr how many steps i need to reach a floor,i just want to count how many times the hall sensor changes from low to high...

tuxduino

To make the hall sensor counts useful you still have to know the distance covered by the elevator for each hall sensor transition. That's not very different from knowing how many cm you elevator travels per motor step.

Go Up