Updated sketch with resistor