This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
#from time import sleep # Import the sleep function from the time module | |
import os | |
import csv | |
r = csv.reader(open('/home/pi/Desktop/hydroponic_project/relay_running_count.csv')) # Here your csv file | |
lines = list(r) | |
original = lines[0][0] | |
print(lines[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
import os | |
import csv | |
GPIO.setmode(GPIO.BCM) | |
#pin bawah skali, seblah ground | |
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
from time import sleep # Import the sleep function from the time module | |
GPIO.setwarnings(False) # Ignore warning for now | |
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering | |
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and s$ | |
while True: # Run forever | |
GPIO.output(8, GPIO.HIGH) # Turn on | |
sleep(1) # Sleep for 1 second -> use this to set the interval for water pump | |
GPIO.output(8, GPIO.LOW) # Turn off | |
sleep(1) # Sleep for 1 second |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Copyright (c) 2017-18 Richard Hull and contributors | |
# See LICENSE.rst for details. | |
import re | |
import time | |
import argparse | |
from luma.led_matrix.device import max7219 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Crops | |
attr_accessor :sam #declare a variable named sam here | |
attr_accessor :luke #declare a variable named luke here | |
def initialize() | |
@sam = ["apple", "carrot"] #declare that sam has what | |
@luke = ["carrot"] #declare that luke has what | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Please select crop number and separated by comma if more than one : \n 1) apple \n 2) pear" | |
a = gets.chomp | |
#receive string with comma separated | |
b = a.split(",") | |
# puts "#{b}" | |
b.each do |x| | |
#received string. convert to integer first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mImageView = (ImageView) findViewById(R.id.imageView1); | |
mImageView.setImageResource(R.drawable.camera); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getLatestCounterNumber() { | |
var int = 0 | |
ref = Database.database().reference() | |
ref.observeSingleEvent(of: .value, with: { snapshot in | |
if !snapshot.exists() { return } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//swift 4.0 | |
func convertpdfToImage(url: URL) -> UIImage? { | |
guard let document = CGPDFDocument(url as CFURL) else { return nil } | |
guard let page = document.page(at: 1) else { return nil } | |
let pageRect = page.getBoxRect(.mediaBox) | |
let renderer = UIGraphicsImageRenderer(size: pageRect.size) | |
let img = renderer.image { ctx in | |
UIColor.white.set() | |
ctx.fill(pageRect) |
NewerOlder