-
Oct 29th, 2024, 02:48 PM
#1
Thread Starter
Banned
step by step walkthrough for adding a temperature read skill for a LivinGrimoire obje

the temperature is read from an LM35 (temperature) sensor, connected to an Arduino or Elegoo
microcontroller.
the merit of this example is reading serial input from the Arduino,
inside the computer connected to it.
there are 2 parts to adding the skill:
1. adding the skill to the Arduino
in the Arduino IDE:
tools: select board and port connecting to the Arduino/elegoo
Sketch->Include Library->Add .ZIP Library...
select the LivinGrimoireLight290724.zip
LivinGrimoireLight link
add the temperature skill files (DiTemperature.h and DiTemperature.cpp)
Arduino temperature skill link
add the temperature read skill in the main Arduino code:
Code:
#include "DiTemperature.h"
#include "LivinGrimoireLight.h"
Chobit* c1;
void setup() {
Skill* s2 = new DiTemperature(0); // temperature skill created LM35 connected to analog pin 0
c1 = new Chobit();
c1->addSkill(s2);
}
void loop() {
c1->think(0, 0, 0);
}
2. adding the skill to the laptop (PyCharm IDE)
(terminal) pip install pyserial
#######################################################
adding the DLC_Arduino_skills from the python directory:
skill_DLC
in the main file add this function(Python code):
Code:
import os
# noinspection PyUnusedLocal
def call_add_DLC_skills(brain: Brain):
for file in os.listdir('.'):
if file.endswith('.py') and 'DLC' in file:
module_name = file[:-3]
exec(f"import {module_name}")
exec(f"{module_name}.add_DLC_skills(brain)")
in the running code area add:
call_add_DLC_skills(brain)
this will add skills via .py files with DLC in their file name.
Last edited by NTShpikho; Oct 29th, 2024 at 03:26 PM.
-
Oct 29th, 2024, 03:07 PM
#2
Thread Starter
Banned
Re: step by step walkthrough for adding a temperature read skill for a LivinGrimoire
note the above walkthrough includes some initial setup for elaboration.
this means adding additional skills is even shorter.
just add the skill files, and 1 code line per skill on the Arduino/Elegoo main code file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|