jizzduino

fukurou

the supreme coder
ADMIN
C++:
void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud rate
}

void loop() {
  Serial.println("Hello from Arduino!"); // Send a message
  delay(1000); // Wait for 1 second
}
 

fukurou

the supreme coder
ADMIN
C++:
#include "DiTemperature.h"
#include "LivinGrimoireLight.h"

Chobit* c1;
Skill* s2 = new DiTemperature(0);
void setup() {
     // temperature skill created LM35 connected to analog pin 0
    c1 = new Chobit();
    c1->addSkill(s2);   
}

void loop() {
    c1->think(0, 0, 0);
}
 

fukurou

the supreme coder
ADMIN
.h file
C++:
#ifndef DiTemperature_H
#define DiTemperature_H
// using Arduino hardware codes outside main:
#include <Arduino.h>
#include "LivinGrimoireLight.h"

/*
lm35 sketch
prints the temperature to the serial monitor
*/

class DiTemperature : public Skill {
    private:
        int _inPin; // analog pin
    public:
    DiTemperature(int inPin);
    virtual void inOut(byte ear, byte skin, byte eye);
};
#endif
 

fukurou

the supreme coder
ADMIN
.cpp:
C++:
#include <Arduino.h>
#include "DiTemperature.h"
#include "LivinGrimoireLight.h"

DiTemperature::DiTemperature(int inPin)
{
  _inPin = inPin;
  Serial.begin(9600); // Start serial communication at 9600 baud
}

void DiTemperature::inOut(byte ear, byte skin, byte eye) {
  Serial.println("Hello from Arduino!"); // Send a message
  delay(1000);
  // Serial.print(" \xC2\xB0"); // shows degree symbol
  // Serial.println("C");
}
 

fukurou

the supreme coder
ADMIN
temp getter!
C++:
#include <Arduino.h>
#include "DiTemperature.h"
#include "LivinGrimoireLight.h"

DiTemperature::DiTemperature(int inPin)
{
  _inPin = inPin;
  Serial.begin(9600); // Start serial communication at 9600 baud
}

void DiTemperature::inOut(byte ear, byte skin, byte eye) {
  int value = analogRead(_inPin);
  float millivolts = (value / 1024.0) * 5000;
  float celsius = millivolts / 10;
  Serial.print(celsius);
  delay(1000);
  // Serial.print(" \xC2\xB0"); // shows degree symbol
  // Serial.println("C");
}

shit in the ass!
 

fukurou

the supreme coder
ADMIN
Python:
import serial
import time

def read_serial_data(port='COM3', baud_rate=9600, num_readings=10, timeout=1):
    ser = serial.Serial(port, baud_rate, timeout=timeout)
    
    readings = []
    for _ in range(num_readings):
        if ser.in_waiting > 0:
            line = ser.readline().decode('utf-8').rstrip()
            readings.append(line)
            print(line)
        time.sleep(1)  # Delay between readings

    ser.close()
    return readings

# Example usage
if __name__ == '__main__':
    data = read_serial_data()
 

fukurou

the supreme coder
ADMIN
Python:
import serial
import time

class SerialReader:
    def __init__(self, port='COM3', baud_rate=9600, timeout=1):
        self.ser = serial.Serial(port, baud_rate, timeout=timeout)

    def read_serial_data(self, num_readings=10):
        readings = []
        for _ in range(num_readings):
            if self.ser.in_waiting > 0:
                line = self.ser.readline().decode('utf-8').rstrip()
                readings.append(line)
                print(line)
            time.sleep(1)  # Delay between readings
        return readings

    def close(self):
        self.ser.close()

# Example usage
if __name__ == '__main__':
    reader = SerialReader()
    data = reader.read_serial_data()
    reader.close()
 

fukurou

the supreme coder
ADMIN
Python:
import serial
import time
import atexit

class SerialReader:
    def __init__(self, port='COM3', baud_rate=9600, timeout=1):
        self.ser = serial.Serial(port, baud_rate, timeout=timeout)
        atexit.register(self.close)  # Register the close method to be called on exit

    def read_serial_data(self, num_readings=10):
        readings = []
        for _ in range(num_readings):
            if self.ser.in_waiting > 0:
                line = self.ser.readline().decode('utf-8').rstrip()
                readings.append(line)
                print(line)
            time.sleep(1)  # Delay between readings
        return readings

    def close(self):
        self.ser.close()

# Example usage
if __name__ == '__main__':
    reader = SerialReader()
    data = reader.read_serial_data()
 

fukurou

the supreme coder
ADMIN
Python:
import serial
import time
import atexit

class SerialReader:
    def __init__(self, port='COM3', baud_rate=9600, timeout=1):
        self.ser = serial.Serial(port, baud_rate, timeout=timeout)
        atexit.register(self.close)  # Register the close method to be called on exit

    def read_serial_data(self, num_readings=10):
        readings = []
        for _ in range(num_readings):
            if self.ser.in_waiting > 0:
                line = self.ser.readline().decode('utf-8').rstrip()
                readings.append(line)
                print(line)
            time.sleep(1)  # Delay between readings
        return readings

    def close(self):
        self.ser.close()

# Example usage
if __name__ == '__main__':
    reader = SerialReader()
    data = reader.read_serial_data()
 
Top