c - What language should I use for an automatic gear shifting program? -
i thinking writing program automatically change gear of bike. may require microprocessor, question had in mind was: there different language programming microprocessor or can done using c , c++?
another thing is, regarding program, can switch statement work or need pointer or linked list because gear works both ways, , down? bit confused switch statement thing!
one solution designed prototyping , hobby applications basic stamp, based on pic microcontroller including interpreter. programmed in basic rather c/c++ if looking for. keep in mind that there are microcontrollers "worse" 1 have; have programmed in assembly language.
no pointers or linked lists required, because microcontrollers have severely limited memory capacity.
switchstatement work fine; remember include break statements avoid problems fall-through. it's possible use bit-shifting. yes, curd's answer has truth in it:porta = porta & ~0x07 | (1 << selected_gear);where selectedgear starts @ 0 , bike has 3 speeds. write code read sensor inputs , determine correct gear bike should in. so, use finite state machine.
Comments
Post a Comment