summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeaufour2004-05-18 17:00:18 +0000
committerbeaufour2004-05-18 17:00:18 +0000
commit5af26ff4016fdd2a14abd5d7e4540e87161822e4 (patch)
tree3c056daa6be2ee0cc94c0008ab01d2f318db702e
parent4fda347a9166d249073913cc1da8b9e25a6ce0cc (diff)
Initial revision
-rw-r--r--2004/n/mini/mini.c103
-rw-r--r--2004/n/mini/mini.h4
2 files changed, 107 insertions, 0 deletions
diff --git a/2004/n/mini/mini.c b/2004/n/mini/mini.c
new file mode 100644
index 0000000..0ed4a76
--- /dev/null
+++ b/2004/n/mini/mini.c
@@ -0,0 +1,103 @@
+/* mini.c */
+/* APBTeam - Programme du petit Robot 2004 {{{
+ *
+ * Copyright (C) 2003 Pierre-André Galmes
+ *
+ * Robot APB Team/Efrei 2004.
+ * Web: http://assos.efrei.fr/robot/
+ * Mail: robot AT efrei DOT fr
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+
+/* Principe :
+ *
+ * Le mini robot est composé d'un servo utilisé comme moteur pour avancer
+ * et reculer. Il fait des allez-retours. Dès qu'il touche un bord, il appuie
+ * sur un interrupteur et repart dansl'autre sens !
+ *
+*/
+
+/* TODO
+ 1 - penser à faire arrêter le petit robot au bout de 1m30.
+*/
+
+#include "mini.h"
+
+
+/* Définitions. */
+#define S_CHANGE 1
+#define S_FORWARD 0
+#define S_BACKWARD 1
+
+
+/* Programme Principal. */
+void main()
+{
+ unsigned short sens = S_FORWARD;
+ unsigned short changed = FALSE;
+
+
+ setup_adc_ports(NO_ANALOGS);
+ setup_adc(ADC_CLOCK_DIV_2);
+ setup_spi(FALSE);
+ setup_counters(RTCC_INTERNAL,WDT_18MS);
+ setup_timer_1(T1_DISABLED);
+ setup_timer_2(T2_DISABLED,0,1);
+
+
+ while (1)
+ {
+
+ /* Changer de sens. */
+ if ((input (PIN_B4) == S_CHANGE) && (changed == FALSE))
+ {
+ changed = TRUE;
+
+ if (sens == S_FORWARD)
+ sens = S_BACKWARD;
+ else
+ sens = S_FORWARD;
+ }
+ /* Vérifier que l'on arrête d'appuyer sur le micro-switch. */
+ else if (input (PIN_B4) != S_CHANGE)
+ {
+ changed = FALSE;
+ }
+
+
+ /* Aller en avant. */
+ if (sens == S_FORWARD)
+ {
+ /* Faire un cycle */
+ output_low(PIN_B7);
+ delay_ms (18);
+
+ output_high (PIN_B7);
+ delay_ms (2);
+ }
+ /* Aller en arrière. */
+ else
+ {
+ /* Faire un cycle */
+ output_low (PIN_B7);
+ delay_us (19000);
+
+ output_high (PIN_B7);
+ delay_us (1000);
+ }
+ }
+}
diff --git a/2004/n/mini/mini.h b/2004/n/mini/mini.h
new file mode 100644
index 0000000..9cc642c
--- /dev/null
+++ b/2004/n/mini/mini.h
@@ -0,0 +1,4 @@
+#include <16F876.h>
+#use delay(clock=4000000)
+#fuses XT,WDT
+