|
@@ -14,7 +14,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 5,
|
|
|
+ "execution_count": 4,
|
|
|
"id": "4e6dfa60",
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
@@ -22,9 +22,11 @@
|
|
|
"class MCSArduino(Arduino):\n",
|
|
|
" pin_diode = 13\n",
|
|
|
" pin_TTL = 6\n",
|
|
|
+ " pin_LED_lights = 7\n",
|
|
|
" \n",
|
|
|
" def __init__(self, *args, **kwargs):\n",
|
|
|
" self.last_cmd = False # False - Arduino LOW, True - Arduino HIGH\n",
|
|
|
+ " self.is_light_off = False\n",
|
|
|
" super(MCSArduino, self).__init__(*args, **kwargs)\n",
|
|
|
" \n",
|
|
|
" def start_or_stop(self):\n",
|
|
@@ -32,6 +34,10 @@
|
|
|
" self.digital[MCSArduino.pin_diode].write(self.last_cmd)\n",
|
|
|
" self.digital[MCSArduino.pin_TTL].write(self.last_cmd)\n",
|
|
|
"\n",
|
|
|
+ " def switch_light(self):\n",
|
|
|
+ " self.is_light_off = not self.is_light_off\n",
|
|
|
+ " self.digital[MCSArduino.pin_LED_lights].write(self.is_light_off)\n",
|
|
|
+ " \n",
|
|
|
"class FakeArduino():\n",
|
|
|
" def start_or_stop(self):\n",
|
|
|
" print(\"Fake Arduino - sending a TTL pulse\")\n",
|
|
@@ -70,7 +76,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 20,
|
|
|
+ "execution_count": 9,
|
|
|
"id": "f1050f57",
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
@@ -78,6 +84,17 @@
|
|
|
"board = MCSArduino('COM10') # Windows - 'COM10', Linux - '/dev/ttyACM0', check /dev/tty*"
|
|
|
]
|
|
|
},
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 11,
|
|
|
+ "id": "e8470dc1",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "# check the light on-off\n",
|
|
|
+ "board.switch_light()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": 21,
|
|
@@ -93,7 +110,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 19,
|
|
|
+ "execution_count": 12,
|
|
|
"id": "97ae6ba1",
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|