Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
The code for a flower pot that has a built-in sensor to detects when the soil is dry and lets you know. The circuit uses an ATtiny85 as the brain and copper tape as the sensor.
ATtiny Indoor Plant
This program flashes a blue light when there is dry dirt.
Pin OUT (only pins that are shown are used)
--[[()]]-- 5V
A3 --[[[]]]--
GND --[[[]]]-- D0
Created by Peter Flickinger ( )
With help from
Parts can be bought from or from this wish list
Instructions can be found on Instructables:
Published on December 11, 2014
int dirt = 3; //dirt is an analog pin
int blue = 0; //blue is a digital pin
int threshold = 475; //This is the light level that determins wheather it is bright or dark
void setup() {
pinMode(blue, OUTPUT);
void loop() {
int moisture = analogRead(dirt);
//This is the decision part
if(moisture >= threshold) {
//If the dirt is dry then blink
//The number is how many times to blink in a second and the blue is which pin to make blink
//else just wait one second before checking again
//this function will blink the PIN a certain amount of TIMES in a second
void blink(int times, int pin){
int time = 1000/times;
for (int i=1; i <= times; i++){
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.