Skip to content

Commit

Permalink
Basic Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
caseybarajas committed Dec 27, 2023
1 parent 0191ce7 commit 6fa73d1
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 26 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ZeroDuino

ZeroDuino is a project that allows you to connect and control an Arduino board using a Raspberry Pi through a Python/Flask-based web interface.

## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)

## Introduction

The ZeroDuino project aims to provide a convenient way to interact with an Arduino board using a Raspberry Pi. By leveraging the power of Python and Flask, it allows you to control the Arduino's inputs and outputs through a web-based interface.

## Features

- Web-based interface for controlling Arduino inputs and outputs
- Real-time monitoring of Arduino sensor data
- Support for multiple Arduino boards
- Easy integration with existing Python projects

## Requirements

To use ZeroDuino, you will need the following:

- Raspberry Pi with Ubuntu 20.04 Server
- Arduino board
- Python 3.x
- Flask

## Installation

1. Clone the ZeroDuino repository to your Raspberry Pi:

```shell
git clone https://github.com/Laughable33/ZeroDuino.git
```

2. Install the required Python packages:

```shell
pip install -r requirements.txt
```

3. Connect your Arduino board to the Raspberry Pi.

## Usage

1. Navigate to the project directory:

```shell
cd ZeroDuino
```

2. Start the Flask server:

```shell
python app.py
```

3. Open a web browser and enter the following URL:

```
http://localhost:5000
```

4. You should now see the ZeroDuino web interface. Use it to control and monitor your Arduino board.

## Contributing

Contributions to the ZeroDuino project are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

## License

This project is licensed under the [MIT License](LICENSE).
24 changes: 11 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
from flask import Flask, render_template, request
from flask import Flask, request
import serial
import time

app = Flask(__name__)
arduino = serial.Serial('/dev/ttyACM0', 9600)

ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
ser.flush()
def send_to_arduino(speed):
arduino.write(f"{speed}\n".encode())

@app.route('/')
def index():
return render_template('index.html')

@app.route('/send_text', methods=['POST'])
def send_text():
text = request.form['text']
ser.write(text.encode()) # Send the text to the Arduino
return ('', 204)
@app.route('/motor', methods=['POST'])
def motor():
speed = request.form.get('speed', type=int)
send_to_arduino(speed)
return f"Motor set to {speed}"

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
app.run(host='0.0.0.0', port=8080)
17 changes: 17 additions & 0 deletions main.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <Servo.h>

Servo motor;

void setup() {
Serial.begin(9600);
motor.attach(9); // Attach the motor to pin 9
}

void loop() {
if (Serial.available() > 0) {
int speed = Serial.parseInt(); // Read the speed value sent from the Raspberry Pi
if (speed >= 0 && speed <= 180) {
motor.write(speed); // Set the motor speed
}
}
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
serial
13 changes: 0 additions & 13 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Control LCD</title>
</head>
<body>
<h1>Send Text to LCD</h1>
<form action="/send_text" method="post">
<input type="text" name="text" placeholder="Enter text" required>
<button type="submit">Send</button>
</form>
</body>
</html>

0 comments on commit 6fa73d1

Please sign in to comment.