123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #define BOARD Versa1
- #include <fruit.h>
- #include <analog.h>
- #include <dcmotor.h>
- t_delay mainDelay;
- DCMOTOR_DECLARE(A);
- DCMOTOR_DECLARE(B);
- void setup(void) {
- fruitInit();
-
- pinModeDigitalOut(LED);
- digitalClear(LED);
- delayStart(mainDelay, 5000);
- analogInit();
- analogSelect(0, MOTA_CURRENT);
- analogSelect(1, MOTB_CURRENT);
- dcmotorInit(A);
- dcmotorInit(B);
- }
- void loop() {
- fraiseService();
- analogService();
- if(delayFinished(mainDelay))
- {
- delayStart(mainDelay, 5000);
- analogSend();
- DCMOTOR_COMPUTE(A,SYM);
- DCMOTOR_COMPUTE(B,SYM);
- }
- }
- void fraiseReceiveChar()
- {
- unsigned char c;
-
- c=fraiseGetChar();
- if(c=='L'){
- c=fraiseGetChar();
- digitalWrite(LED, c!='0');
- }
- else if(c=='E') {
- printf("C");
- c = fraiseGetLen();
- while(c--) printf("%c",fraiseGetChar());
- putchar('\n');
- }
- }
- void fraiseReceive()
- {
- unsigned char c;
- c=fraiseGetChar();
-
- switch(c) {
- case 120 : DCMOTOR_INPUT(A) ; break;
- case 121 : DCMOTOR_INPUT(B) ; break;
- }
- }
|