control 5v or gnd pin (on/off)

I'm using the board atmega 32u4 as Aduino Leonard.
I want to control the on/off of the another element
When connected to the 5v output pin and the gnd, it operates normally.
It does not work if i use pinmode on the digital pin. Use analogRead() to read the voltage.
The digitalWrite(pin,HIGH) state's output is 1023 when i don't connect element.
As soon as i connect the element, the voltage value drops to 23 and the element does not work.
Conversely, connect the + of the element to the 5 V output pin and - of the element to the digital pin and using the digital pin as the gnd
I tried, but it also doesn't work.

Can i control gnd pin? or 5v pin? or is there any other way??

The element also operates on a 1.5v battery.

The element is peltier.

Peltier devices use a lot of power, so the current will be high. Arduino pins cannot handle more than 40mA,
and its best to keep well below that limit.

You need to switch the power using a device capable of the current.

You’ve neglected the datasheet for the Peltier device, we need all these details.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Please attach code and wiring diagram.

hsl323:
Can i control gnd pin? or 5v pin? or is there any other way??

Yes, you can control either. The simplest will be to control the ground on the peltier load using a MOSFET. Connecting an N-Channel MOSFET - Arduino Project Hub
Since the peltier junction is running on the same or a lower voltage than the MCU, a simple PNP high-side switch would be an option: PNP Transistor Switching
If the current drawn by your peltier element is more than a few amps, you may want to consider using a relay to control it. https://circuitdigest.com/microcontroller-projects/arduino-relay-control